Compare commits

..

No commits in common. "main" and "main" have entirely different histories.
main ... main

22 changed files with 192 additions and 591 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

View File

@ -6,7 +6,7 @@
<groupId>me.NVus</groupId> <groupId>me.NVus</groupId>
<artifactId>NVus_Prison</artifactId> <artifactId>NVus_Prison</artifactId>
<version>1.1.8</version> <version>1.0.8</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>NVus_PrisonSetup</name> <name>NVus_PrisonSetup</name>

View File

@ -1,21 +0,0 @@
package me.nvus.nvus_prison_setup.AutoSell;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.entity.Player;
public class EconomyHandler {
private Economy economy;
private MultiplierManager multiplierManager;
public EconomyHandler(Economy economy, MultiplierManager multiplierManager) {
this.economy = economy;
this.multiplierManager = multiplierManager;
}
public void giveMoney(Player player, double amount) {
double multiplier = multiplierManager.getPlayerMultiplier(player.getUniqueId());
economy.depositPlayer(player, amount * multiplier);
}
}

View File

@ -19,10 +19,9 @@ public class AutoSellListener implements Listener {
@EventHandler @EventHandler
public void onBlockBreak(BlockBreakEvent event) { public void onBlockBreak(BlockBreakEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
// Added additional permission check if (!player.hasPermission("nvus.prisoner") || !sellManager.isAutoSellEnabled(player)) {
if ((sellManager.isAutoSellEnabled(player)) ) { return;
}
sellManager.sellItems(player); sellManager.sellItems(player);
} }
} }
}

View File

@ -1,87 +0,0 @@
package me.nvus.nvus_prison_setup.AutoSell;
import me.nvus.nvus_prison_setup.PrisonSetup;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
public class MultiplierManager implements CommandExecutor {
private final PrisonSetup plugin;
private final Map<UUID, Double> multipliers = new HashMap<>();
// Store the scheduled tasks for removing multipliers
private final Map<UUID, BukkitTask> removalTasks = new HashMap<>();
public MultiplierManager(PrisonSetup plugin) {
this.plugin = plugin; // Store the passed plugin instance for later use
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!sender.hasPermission("multiplier.use")) {
sender.sendMessage("You don't have permission to use this command.");
return true;
}
if (args.length != 3) {
sender.sendMessage("Usage: /multiplier <player> <multiplier> <duration in minutes>");
return true;
}
Player target = Bukkit.getPlayer(args[0]);
if (target == null) {
sender.sendMessage("Player not found.");
return true;
}
try {
double multiplier = Double.parseDouble(args[1]);
int duration = Integer.parseInt(args[2].replace("m", ""));
applyMultiplier(target, multiplier, duration);
sender.sendMessage("Applied a " + multiplier + "x multiplier to " + target.getName() + " for " + duration + " minutes.");
} catch (NumberFormatException e) {
sender.sendMessage("Invalid number format.");
}
return true;
}
private void applyMultiplier(Player player, double multiplier, int duration) {
UUID playerId = player.getUniqueId();
// Cancel any existing removal task
if (removalTasks.containsKey(playerId)) {
removalTasks.get(playerId).cancel();
removalTasks.remove(playerId);
}
// Apply the new multiplier
multipliers.put(playerId, multiplier);
// Schedule a new removal task
BukkitTask task = new BukkitRunnable() {
@Override
public void run() {
multipliers.remove(playerId);
removalTasks.remove(playerId);
player.sendMessage("Your selling multiplier has expired.");
}
}.runTaskLater(plugin, duration * 60 * 20); // Convert minutes to ticks
// Store the task for potential cancellation
removalTasks.put(playerId, task);
player.sendMessage("Applied a " + multiplier + "x multiplier to you for " + duration + " minutes.");
}
public double getPlayerMultiplier(UUID playerUuid) {
return multipliers.getOrDefault(playerUuid, 1.0); // Default to 1.0, meaning no multiplier
}
}

View File

@ -2,7 +2,6 @@ package me.nvus.nvus_prison_setup.AutoSell;
import me.nvus.nvus_prison_setup.Configs.ConfigManager; import me.nvus.nvus_prison_setup.Configs.ConfigManager;
import me.nvus.nvus_prison_setup.PrisonSetup; import me.nvus.nvus_prison_setup.PrisonSetup;
import me.nvus.nvus_prison_setup.AutoSell.MultiplierManager;
import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.economy.Economy;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
@ -19,53 +18,29 @@ import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.time.LocalDateTime;
public class SellManager implements CommandExecutor { public class SellManager implements CommandExecutor {
private final HashMap<UUID, Boolean> autoSellStatus = new HashMap<>(); private final HashMap<UUID, Boolean> autoSellStatus = new HashMap<>();
private final HashMap<Material, Double> prices = new HashMap<>(); private final HashMap<Material, Double> prices = new HashMap<>();
private final Map<UUID, MultiplierInfo> playerMultipliers = new ConcurrentHashMap<>();
private final ConfigManager configManager; private final ConfigManager configManager;
private final MultiplierManager multiplierManager;
public SellManager(ConfigManager configManager, MultiplierManager multiplierManager) { public SellManager(ConfigManager configManager) {
this.configManager = configManager; this.configManager = configManager;
this.multiplierManager = multiplierManager;
loadPrices(); loadPrices();
} }
private static class MultiplierInfo {
double multiplier;
LocalDateTime expiryTime;
MultiplierInfo(double multiplier, int durationMinutes) {
this.multiplier = multiplier;
this.expiryTime = LocalDateTime.now().plusMinutes(durationMinutes);
}
boolean isExpired() {
return LocalDateTime.now().isAfter(expiryTime);
}
}
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) { if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "Only players can use this command."); sender.sendMessage("Only players can use this command.");
return true; return true;
} }
Player player = (Player) sender; Player player = (Player) sender;
// Admin Commands: // Admin Commands:
if ("setprice".equalsIgnoreCase(label)) { if ("setprice".equalsIgnoreCase(command.getName())) {
if (!player.hasPermission("nvus.admin")) { if (player.hasPermission("nvus.admin")) {
player.sendMessage(ChatColor.RED + "You do not have permission to set prices.");
return true;
}
if (args.length != 1) { if (args.length != 1) {
player.sendMessage(ChatColor.RED + "Usage: /setprice <price>"); player.sendMessage(ChatColor.RED + "Usage: /setprice <price>");
return true; return true;
@ -76,34 +51,25 @@ public class SellManager implements CommandExecutor {
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
player.sendMessage(ChatColor.RED + "Please provide a valid price."); player.sendMessage(ChatColor.RED + "Please provide a valid price.");
} }
} else {
player.sendMessage(ChatColor.RED + "You do not have permission to set prices.");
}
return true; return true;
} }
// Player/Prisoner Commands: // Player/Prisoner Commands:
switch (label.toLowerCase()) { switch (command.getName().toLowerCase()) {
case "autosell": case "autosell":
if (player.hasPermission("nvus.prisoner") || player.hasPermission("nvus.autosell")) {
toggleAutoSell(player); toggleAutoSell(player);
} else {
player.sendMessage(ChatColor.RED + "You do not have permission to use /autosell.");
}
break; break;
case "sellall": case "sellall":
if (player.hasPermission("nvus.prisoner") || player.hasPermission("nvus.sellall")) {
sellItems(player); sellItems(player);
} else {
player.sendMessage(ChatColor.RED + "You do not have permission to use /sellall.");
}
break; break;
default:
// More commands in future? xD
return false;
} }
return true; return true;
} }
private void loadPrices() { private void loadPrices() {
FileConfiguration itemPricesConfig = configManager.getItemPricesConfig(); FileConfiguration itemPricesConfig = configManager.getItemPricesConfig();
ConfigurationSection pricesSection = itemPricesConfig.getConfigurationSection("Prices"); ConfigurationSection pricesSection = itemPricesConfig.getConfigurationSection("Prices");
@ -180,10 +146,10 @@ public class SellManager implements CommandExecutor {
} }
public void sellItems(Player player) { public void sellItems(Player player) {
// if (player.hasPermission("nvus.prisoner") || player.hasPermission("nvus.sellall")) { if (!player.hasPermission("nvus.prisoner")) {
// player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c&lYou do not have permission to use this command.")); player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c&lYou do not have permission to use this command."));
// return; return;
// } }
Map<Material, Integer> soldItems = new HashMap<>(); Map<Material, Integer> soldItems = new HashMap<>();
@ -204,20 +170,11 @@ public class SellManager implements CommandExecutor {
private void giveMoney(Player player, Material material, int quantity, double amount) { private void giveMoney(Player player, Material material, int quantity, double amount) {
Economy economy = PrisonSetup.getEconomy(); Economy economy = PrisonSetup.getEconomy();
double multiplier = multiplierManager.getPlayerMultiplier(player.getUniqueId()); economy.depositPlayer(player, amount);
double finalAmount = amount * multiplier; // Apply the multiplier
economy.depositPlayer(player, finalAmount);
player.sendMessage(ChatColor.translateAlternateColorCodes('&', player.sendMessage(ChatColor.translateAlternateColorCodes('&',
String.format("&a&lSold &d%dx &3%s &a&lfor $%.2f", quantity, material.toString().toLowerCase().replaceAll("_", " "), finalAmount))); String.format("&a&lSold &d%dx &3%s &a&lfor $%.2f", quantity, material.toString().toLowerCase().replaceAll("_", " "), amount)));
} }
// private void giveMoney(Player player, Material material, int quantity, double amount) {
// Economy economy = PrisonSetup.getEconomy();
// economy.depositPlayer(player, amount);
// player.sendMessage(ChatColor.translateAlternateColorCodes('&',
// String.format("&a&lSold &d%dx &3%s &a&lfor $%.2f", quantity, material.toString().toLowerCase().replaceAll("_", " "), amount)));
// }
// public void sellItems(Player player) { // public void sellItems(Player player) {

View File

@ -41,21 +41,13 @@ public class SettingsMenu implements Listener {
inv.setItem(4, createToggleItem(Material.LEVER, "Toggle AutoSwitch", config.getBoolean("AutoSwitch", true))); inv.setItem(4, createToggleItem(Material.LEVER, "Toggle AutoSwitch", config.getBoolean("AutoSwitch", true)));
inv.setItem(5, createToggleItem(Material.IRON_PICKAXE, "Toggle ToolDamage", config.getBoolean("ToolDamage", false))); inv.setItem(5, createToggleItem(Material.IRON_PICKAXE, "Toggle ToolDamage", config.getBoolean("ToolDamage", false)));
inv.setItem(7, createToggleItem(Material.IRON_BARS , "Toggle PrisonerGangs", false));
inv.setItem(8, createToggleItem(Material.BOOK, "Reload Configs", false)); inv.setItem(8, createToggleItem(Material.BOOK, "Reload Configs", false));
// Second Row // Second Row
inv.setItem(9, createToggleItem(Material.GOLD_INGOT, "Toggle AutoSell", config.getBoolean("AutoSell", true))); inv.setItem(9, createToggleItem(Material.GOLD_INGOT, "Toggle AutoSell", config.getBoolean("AutoSell", true)));
inv.setItem(10, createToggleItem(Material.GOLD_BLOCK, "Toggle SellAll", config.getBoolean("SellAll", true))); inv.setItem(10, createToggleItem(Material.GOLD_BLOCK, "Toggle SellAll", config.getBoolean("SellAll", true)));
inv.setItem(12, createToggleItem(Material.OAK_SAPLING, "Toggle TreeFarm", config.getBoolean("TreeFarm", true))); inv.setItem(11, createToggleItem(Material.OAK_SAPLING, "Toggle TreeFarm", config.getBoolean("TreeFarm", true)));
inv.setItem(13, createToggleItem(Material.SUNFLOWER, "Toggle PrisonerRanks", config.getBoolean("PrisonerRanks", true)));
inv.setItem(15, createToggleItem(Material.IRON_SHOVEL, "Toggle PrisonerKit", config.getBoolean("PrisonerKit", true)));
inv.setItem(16, createToggleItem(Material.BARRIER, "Toggle RestrictKitDrop", config.getBoolean("RestrictKitDrop", true)));
inv.setItem(17, createToggleItem(Material.BARRIER, "Toggle RestrictKitMove", config.getBoolean("RestrictKitMove", true)));
player.openInventory(inv); player.openInventory(inv);
} }
@ -110,28 +102,10 @@ public class SettingsMenu implements Listener {
toggleConfigOption(player, "AutoSwitch"); toggleConfigOption(player, "AutoSwitch");
} else if (displayName.contains("Toggle AutoSell")) { } else if (displayName.contains("Toggle AutoSell")) {
toggleConfigOption(player, "AutoSell"); toggleConfigOption(player, "AutoSell");
player.sendMessage(ChatColor.GREEN + "Requires a server restart to take effect. Or external plugin reload ie PlugManX");
} else if (displayName.contains("Toggle SellAll")) { } else if (displayName.contains("Toggle SellAll")) {
toggleConfigOption(player, "SellAll"); toggleConfigOption(player, "SellAll");
player.sendMessage(ChatColor.GREEN + "Requires a server restart to take effect. Or external plugin reload ie PlugManX");
} else if (displayName.contains("Toggle TreeFarm")) { } else if (displayName.contains("Toggle TreeFarm")) {
toggleConfigOption(player, "TreeFarm"); toggleConfigOption(player, "TreeFarm");
player.sendMessage(ChatColor.GREEN + "Requires a server restart to take effect. Or external plugin reload ie PlugManX");
} else if (displayName.contains("Toggle PrisonerGangs")) {
toggleConfigOption(player, "PrisonerGangs");
player.sendMessage(ChatColor.GREEN + "Requires a server restart to take effect. Or external plugin reload ie PlugManX");
}
else if (displayName.contains("Toggle PrisonerRanks")) {
toggleConfigOption(player, "PrisonerRanks");
player.sendMessage(ChatColor.GREEN + "Requires a server restart to take effect. Or external plugin reload ie PlugManX");
} else if (displayName.contains("Toggle PrisonerKit")) {
toggleConfigOption(player, "PrisonerKit");
} else if (displayName.contains("Toggle RestrictKitDrop")) {
toggleConfigOption(player, "RestrictKitDrop");
} else if (displayName.contains("Toggle RestrictKitMove")) {
toggleConfigOption(player, "RestrictKitMove");
} else if (displayName.contains("Toggle ToolDamage")) {
toggleConfigOption(player, "ToolDamage");
} else if (displayName.contains("Reload Configs")) { } else if (displayName.contains("Reload Configs")) {
reloadConfigs(player); reloadConfigs(player);
} }
@ -165,7 +139,6 @@ public class SettingsMenu implements Listener {
configManager.reloadConfig("auto_switch.yml"); configManager.reloadConfig("auto_switch.yml");
configManager.reloadConfig("banned_items.yml"); configManager.reloadConfig("banned_items.yml");
configManager.reloadConfig("item_prices.yml"); configManager.reloadConfig("item_prices.yml");
configManager.reloadConfig("ranks.yml");
//configManager.saveConfig("config.yml"); //configManager.saveConfig("config.yml");
player.sendMessage(ChatColor.GREEN + "[NVus Prison] : Configuration files reloaded!"); player.sendMessage(ChatColor.GREEN + "[NVus Prison] : Configuration files reloaded!");
player.closeInventory(); player.closeInventory();

View File

@ -9,7 +9,6 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -66,125 +65,44 @@ public class KitManager {
ItemStack item = new ItemStack(material); ItemStack item = new ItemStack(material);
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
// Configure item meta (name, lore, enchantments)...
// Set the display name if available
if (itemSpec.containsKey("name")) { if (itemSpec.containsKey("name")) {
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', (String) itemSpec.get("name"))); String name = ChatColor.translateAlternateColorCodes('&', (String) itemSpec.get("name"));
meta.setDisplayName(name);
} }
// Set lore if available
if (itemSpec.containsKey("lore")) { if (itemSpec.containsKey("lore")) {
List<String> lore = new ArrayList<>(); List<String> lore = new ArrayList<>();
((List<String>) itemSpec.get("lore")).forEach(line -> lore.add(ChatColor.translateAlternateColorCodes('&', line))); for (String line : (List<String>) itemSpec.get("lore")) {
lore.add(ChatColor.translateAlternateColorCodes('&', line));
}
meta.setLore(lore); meta.setLore(lore);
} }
// Set enchantments if available
if (itemSpec.containsKey("enchantments")) { if (itemSpec.containsKey("enchantments")) {
((Map<String, Integer>) itemSpec.get("enchantments")).forEach((enchant, level) -> meta.addEnchant(Enchantment.getByName(enchant.toUpperCase()), level, true)); Map<String, Integer> enchantments = (Map<String, Integer>) itemSpec.get("enchantments");
for (Map.Entry<String, Integer> enchantmentEntry : enchantments.entrySet()) {
Enchantment enchantment = Enchantment.getByName(enchantmentEntry.getKey());
if (enchantment != null) {
meta.addEnchant(enchantment, enchantmentEntry.getValue(), true);
} }
}
}
item.setItemMeta(meta); item.setItemMeta(meta);
// Set item in specified quickbar slot, if available
if (itemSpec.containsKey("slot")) { if (itemSpec.containsKey("slot")) {
int slot = (Integer) itemSpec.get("slot"); player.getInventory().setItem((Integer) itemSpec.get("slot"), item);
ItemStack existingItem = player.getInventory().getItem(slot);
if (existingItem != null && existingItem.getType() != Material.AIR && !isPrisonerKitItem(existingItem)) {
moveItemToAvailableSlot(player, existingItem);
}
player.getInventory().setItem(slot, item);
} else { } else {
player.getInventory().addItem(item); player.getInventory().addItem(item);
} }
} }
} }
private void moveItemToAvailableSlot(Player player, ItemStack item) {
// Attempt to move the existing item to an available slot
HashMap<Integer, ItemStack> overflow = player.getInventory().addItem(item);
if (!overflow.isEmpty()) {
// Check Ender Chest
if (player.getEnderChest().firstEmpty() != -1) {
player.getEnderChest().addItem(overflow.get(0));
player.sendMessage(ChatColor.YELLOW + "Your inventory was full, so an item was moved to your Ender Chest.");
} else {
// Drop the item at the player's location
player.getWorld().dropItemNaturally(player.getLocation(), overflow.get(0));
player.sendMessage(ChatColor.RED + "Your inventory and Ender Chest were full, so an item was dropped on the ground.");
}
}
}
// public void givePrisonerKit(Player player) {
// if (!configManager.getBoolean("config.yml", "PrisonerKit", false)) {
// return;
// }
//
// FileConfiguration config = configManager.getConfig("config.yml");
// List<Map<?, ?>> kitItems = config.getMapList("PrisonerKitItems");
//
// for (Map<?, ?> itemSpec : kitItems) {
// Material material = Material.matchMaterial((String) itemSpec.get("item"));
// if (material == null) continue;
//
// ItemStack item = new ItemStack(material);
// ItemMeta meta = item.getItemMeta();
//
// // Configure item meta (name, lore, enchantments)...
// // This part remains the same as in your original method
//
// item.setItemMeta(meta);
//
// // Attempt to set the item in the specified slot
// if (itemSpec.containsKey("slot")) {
// int slot = (Integer) itemSpec.get("slot");
// ItemStack existingItem = player.getInventory().getItem(slot);
//
// // If the slot is occupied, try to find a new place for the existing item
// if (existingItem != null && existingItem.getType() != Material.AIR) {
// HashMap<Integer, ItemStack> failedItems = player.getInventory().addItem(existingItem);
//
// // If inventory is full, try ender chest or drop to the ground
// if (!failedItems.isEmpty()) {
// failedItems.forEach((integer, itemStack) -> {
// if (player.getEnderChest().firstEmpty() != -1) {
// player.getEnderChest().addItem(itemStack);
// player.sendMessage(ChatColor.YELLOW + "Some items were moved to your Ender Chest due to a full inventory.");
// } else {
// player.getWorld().dropItemNaturally(player.getLocation(), itemStack);
// player.sendMessage(ChatColor.RED + "Your inventory and Ender Chest are full. Some items were dropped on the ground.");
// }
// });
// }
//
// // Now we can safely place the kit item in the intended slot
// player.getInventory().setItem(slot, item);
// } else {
// // Slot is empty, just place the item there
// player.getInventory().setItem(slot, item);
// }
// } else {
// // No specific slot defined, just add to inventory
// HashMap<Integer, ItemStack> failedItems = player.getInventory().addItem(item);
//
// // Handle full inventory as above
// if (!failedItems.isEmpty()) {
// failedItems.forEach((integer, itemStack) -> {
// if (player.getEnderChest().firstEmpty() != -1) {
// player.getEnderChest().addItem(itemStack);
// player.sendMessage(ChatColor.YELLOW + "Some items were moved to your Ender Chest due to a full inventory.");
// } else {
// player.getWorld().dropItemNaturally(player.getLocation(), itemStack);
// player.sendMessage(ChatColor.RED + "Your inventory and Ender Chest are full. Some items were dropped on the ground.");
// }
// });
// }
// }
// }
// }
} }

View File

@ -2,7 +2,6 @@ package me.nvus.nvus_prison_setup.Kit.Listeners;
import me.nvus.nvus_prison_setup.Configs.ConfigManager; import me.nvus.nvus_prison_setup.Configs.ConfigManager;
import me.nvus.nvus_prison_setup.Kit.KitManager; import me.nvus.nvus_prison_setup.Kit.KitManager;
import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -92,8 +91,7 @@ public class KitListener implements Listener {
if (kitManager.isPrisonerKitItem(droppedItem)) { if (kitManager.isPrisonerKitItem(droppedItem)) {
event.setCancelled(true); event.setCancelled(true);
player.sendMessage(ChatColor.translateAlternateColorCodes('&', "§c&lPER THE WARDEN: You cannot drop your prisoner kit items!")); player.sendMessage("§c&lPER THE WARDEN: You cannot drop your prisoner kit items!");
// player.sendMessage("§c&lPER THE WARDEN: You cannot drop your prisoner kit items!");
} }
} }
@ -116,7 +114,7 @@ public class KitListener implements Listener {
if (kitManager.isPrisonerKitItem(clickedItem)) { if (kitManager.isPrisonerKitItem(clickedItem)) {
event.setCancelled(true); event.setCancelled(true);
player.sendMessage(ChatColor.translateAlternateColorCodes('&', "§c&lPER THE WARDEN: You cannot move your prisoner kit items!")); player.sendMessage("§cPER THE WARDEN: You cannot move your prisoner kit items!");
} }
} }

View File

@ -15,8 +15,6 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory; import org.bukkit.inventory.PlayerInventory;
import org.bukkit.inventory.meta.LeatherArmorMeta; import org.bukkit.inventory.meta.LeatherArmorMeta;
import java.util.HashMap;
public class PlayerArmor implements Listener { public class PlayerArmor implements Listener {
private final ConfigManager configManager; private final ConfigManager configManager;
@ -29,39 +27,25 @@ public class PlayerArmor implements Listener {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (player.hasPermission("nvus.prisoner") && configManager.getConfig("config.yml").getBoolean("PrisonerArmor")) { if (player.hasPermission("nvus.prisoner") && configManager.getConfig("config.yml").getBoolean("PrisonerArmor")) {
PlayerInventory inv = player.getInventory(); PlayerInventory inv = player.getInventory();
ItemStack[] currentArmor = inv.getArmorContents(); inv.setArmorContents(new ItemStack[]{
createArmor(Material.LEATHER_BOOTS, "Prisoner Boots"),
for (int slot = 0; slot < currentArmor.length; slot++) { createArmor(Material.LEATHER_LEGGINGS, "Prisoner Leggings"),
ItemStack armorPiece = currentArmor[slot]; createArmor(Material.LEATHER_CHESTPLATE, "Prisoner Chestplate"),
createArmor(Material.LEATHER_HELMET, "Prisoner Helmet")
// Check if current armor piece is not a prisoner armor, if it's null or AIR (empty slot), or if it's already a prisoner armor piece });
if (armorPiece != null && armorPiece.getType() != Material.AIR && !isPrisonerArmorItem(armorPiece)) {
// Move the non-prisoner armor piece safely before replacing
moveArmorToAvailableSlot(player, armorPiece, slot);
}
}
// After safely moving existing armor, equip new prisoner armor
equipPrisonerArmor(player);
player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&cPer The Warden: &6&lYou have been equipped with standard issue prisoner armor!")); player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&cPer The Warden: &6&lYou have been equipped with standard issue prisoner armor!"));
} }
} }
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)
public void onInventoryClick(InventoryClickEvent event) { public void onInventoryClick(InventoryClickEvent event) {
if (!(event.getWhoClicked() instanceof Player)) return;
Player player = (Player) event.getWhoClicked(); Player player = (Player) event.getWhoClicked();
if (!player.hasPermission("nvus.prisoner")) return; if (!player.hasPermission("nvus.prisoner")) return;
int slot = event.getSlot(); if (event.getClickedInventory() != null && (event.getClickedInventory().getType() == InventoryType.PLAYER || event.getClickedInventory().getType() == InventoryType.CRAFTING)) {
// Correct the slot checks for the inventory interaction if (event.getSlotType() == InventoryType.SlotType.ARMOR || isArmorItem(event.getCurrentItem()) || isArmorItem(event.getCursor())) {
boolean isArmorInteraction = (slot >= 5 && slot <= 8) // Player inventory armor slots (1.8+)
|| (event.getClickedInventory() instanceof PlayerInventory && (slot == 39 || slot == 38 || slot == 37 || slot == 36)); // Correct slots for armor
if (isArmorInteraction && (isPrisonerArmorItem(event.getCurrentItem()) || isPrisonerArmorItem(event.getCursor()))) {
boolean restrictArmor = configManager.getConfig("config.yml").getBoolean("RestrictArmor"); boolean restrictArmor = configManager.getConfig("config.yml").getBoolean("RestrictArmor");
if (restrictArmor) { if (restrictArmor) {
event.setCancelled(true); event.setCancelled(true);
@ -70,21 +54,19 @@ public class PlayerArmor implements Listener {
// If restrictArmor is false, allows the player to change armor freely. // If restrictArmor is false, allows the player to change armor freely.
} }
} }
private boolean isArmorSlot(int slot) {
// Correct the method to align with how armor slots are identified in an InventoryClickEvent
return slot == 39 || slot == 38 || slot == 37 || slot == 36; // The slots for helmet, chestplate, leggings, and boots respectively.
} }
// Checks if the given item is a piece of prisoner armor. // Checks if the given item is a piece of prisoner armor.
private boolean isPrisonerArmorItem(ItemStack item) { private boolean isArmorItem(ItemStack item) {
if (item == null || !item.hasItemMeta()) return false; if (item == null) {
return false;
String itemName = item.getItemMeta().getDisplayName(); }
// Adjust these checks based on how you identify prisoner armor items. Material type = item.getType();
return itemName != null && (itemName.contains("Prisoner Boots") || itemName.contains("Prisoner Leggings") return type == Material.LEATHER_HELMET || type == Material.LEATHER_CHESTPLATE ||
|| itemName.contains("Prisoner Chestplate") || itemName.contains("Prisoner Helmet")); type == Material.LEATHER_LEGGINGS || type == Material.LEATHER_BOOTS ||
// Add checks for other armor materials if prisoners can have those
type == Material.CHAINMAIL_BOOTS || type == Material.IRON_HELMET;
// We can later add additional armor sets here if we allow customization of what is considered "prisoner armor".
} }
private ItemStack createArmor(Material material, String name) { private ItemStack createArmor(Material material, String name) {
@ -97,37 +79,4 @@ public class PlayerArmor implements Listener {
} }
return item; return item;
} }
private void equipPrisonerArmor(Player player) {
ItemStack[] prisonerArmor = new ItemStack[]{
createArmor(Material.LEATHER_BOOTS, "Prisoner Boots"),
createArmor(Material.LEATHER_LEGGINGS, "Prisoner Leggings"),
createArmor(Material.LEATHER_CHESTPLATE, "Prisoner Chestplate"),
createArmor(Material.LEATHER_HELMET, "Prisoner Helmet")
};
player.getInventory().setArmorContents(prisonerArmor);
}
private void moveArmorToAvailableSlot(Player player, ItemStack armorPiece, int armorSlot) {
// Try to add the non-prisoner armor piece to the main inventory
HashMap<Integer, ItemStack> overflow = player.getInventory().addItem(armorPiece);
if (!overflow.isEmpty()) {
// Inventory was full, try the Ender Chest next
if (player.getEnderChest().firstEmpty() != -1) {
player.getEnderChest().addItem(overflow.get(0));
player.sendMessage(ChatColor.YELLOW + "Your inventory was full, so your " + armorPiece.getType() + " was moved to your Ender Chest.");
} else {
// Ender Chest was also full, drop the item at the player's location
player.getWorld().dropItemNaturally(player.getLocation(), overflow.get(0));
player.sendMessage(ChatColor.RED + "Your inventory and Ender Chest were full, so your " + armorPiece.getType() + " was dropped on the ground.");
}
}
// Clear the original armor slot now that we've moved the item
player.getInventory().setItem(armorSlot + 36, new ItemStack(Material.AIR));
}
} }

View File

@ -12,11 +12,8 @@ import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerRespawnEvent; import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.LeatherArmorMeta; import org.bukkit.inventory.meta.LeatherArmorMeta;
import java.util.HashMap;
public class PlayerSpawn implements Listener { public class PlayerSpawn implements Listener {
private final ConfigManager configManager; private final ConfigManager configManager;
@ -58,71 +55,50 @@ public class PlayerSpawn implements Listener {
} }
private void equipPrisonerArmor(Player player) { private void equipPrisonerArmor(Player player) {
handleNonPrisonerArmorItems(player); // Ensure non-prisoner armor is handled before equipping new armor // Create Prisoner Helmet
ItemStack leatherHelmetPrison = new ItemStack(Material.LEATHER_HELMET);
// Define and equip standard prisoner armor LeatherArmorMeta helmetMeta = (LeatherArmorMeta) leatherHelmetPrison.getItemMeta();
ItemStack[] standardPrisonerArmor = new ItemStack[]{ if (helmetMeta != null) {
createArmor(Material.LEATHER_BOOTS, "Prisoner Boots"), helmetMeta.setColor(Color.ORANGE);
createArmor(Material.LEATHER_LEGGINGS, "Prisoner Leggings"), helmetMeta.setDisplayName(ChatColor.GOLD + "Prisoner Helmet");
createArmor(Material.LEATHER_CHESTPLATE, "Prisoner Chestplate"), leatherHelmetPrison.setItemMeta(helmetMeta);
createArmor(Material.LEATHER_HELMET, "Prisoner Helmet")
};
player.getInventory().setArmorContents(standardPrisonerArmor);
player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&cPer The Warden: &6&lYou have been equipped with standard issue prisoner armor!"));
} }
private ItemStack createArmor(Material material, String name) { // Create Prisoner Chestplate
ItemStack item = new ItemStack(material); ItemStack leatherChestplatePrison = new ItemStack(Material.LEATHER_CHESTPLATE);
LeatherArmorMeta meta = (LeatherArmorMeta) item.getItemMeta(); LeatherArmorMeta chestplateMeta = (LeatherArmorMeta) leatherChestplatePrison.getItemMeta();
if (meta != null) { if (chestplateMeta != null) {
meta.setDisplayName(name); chestplateMeta.setColor(Color.ORANGE);
meta.setColor(Color.ORANGE); // Set the color for leather armor chestplateMeta.setDisplayName(ChatColor.GOLD + "Prisoner Chestplate");
item.setItemMeta(meta); leatherChestplatePrison.setItemMeta(chestplateMeta);
}
return item;
} }
private void handleNonPrisonerArmorItems(Player player) { // Create Prisoner Leggings
ItemStack[] armorContents = player.getInventory().getArmorContents(); ItemStack leatherLeggingsPrison = new ItemStack(Material.LEATHER_LEGGINGS);
LeatherArmorMeta leggingsMeta = (LeatherArmorMeta) leatherLeggingsPrison.getItemMeta();
for (int i = 0; i < armorContents.length; i++) { if (leggingsMeta != null) {
ItemStack armorPiece = armorContents[i]; leggingsMeta.setColor(Color.ORANGE);
// Check if the armor piece is not part of the prisoner kit leggingsMeta.setDisplayName(ChatColor.GOLD + "Prisoner Leggings");
if (armorPiece != null && armorPiece.getType() != Material.AIR && !isPrisonerArmorItem(armorPiece)) { leatherLeggingsPrison.setItemMeta(leggingsMeta);
moveArmorToAvailableSlot(player, armorPiece);
armorContents[i] = new ItemStack(Material.AIR); // Remove the non-prisoner armor from the armor slot
}
} }
// Update the player's armor contents after removals // Create Prisoner Boots
player.getInventory().setArmorContents(armorContents); ItemStack leatherBootsPrison = new ItemStack(Material.LEATHER_BOOTS);
LeatherArmorMeta bootsMeta = (LeatherArmorMeta) leatherBootsPrison.getItemMeta();
if (bootsMeta != null) {
bootsMeta.setColor(Color.ORANGE);
bootsMeta.setDisplayName(ChatColor.GOLD + "Prisoner Boots");
leatherBootsPrison.setItemMeta(bootsMeta);
} }
private boolean isPrisonerArmorItem(ItemStack item) { // Equip Prisoner Armor
if (item == null || !item.hasItemMeta()) return false; player.getInventory().setHelmet(leatherHelmetPrison);
ItemMeta meta = item.getItemMeta(); player.getInventory().setChestplate(leatherChestplatePrison);
String itemName = meta.getDisplayName(); player.getInventory().setLeggings(leatherLeggingsPrison);
// Adjust the check based on your naming convention for prisoner armor player.getInventory().setBoots(leatherBootsPrison);
return itemName != null && itemName.contains("Prisoner");
}
private void moveArmorToAvailableSlot(Player player, ItemStack armorPiece) { player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c&lPer The Warden: &6You've been given the default prisoner armor!"));
// Attempt to move the existing armor piece to an available slot
HashMap<Integer, ItemStack> overflow = player.getInventory().addItem(armorPiece);
if (!overflow.isEmpty()) {
// Check Ender Chest
if (player.getEnderChest().firstEmpty() != -1) {
player.getEnderChest().addItem(overflow.get(0));
player.sendMessage(ChatColor.YELLOW + "Your inventory was full, so your armor was moved to your Ender Chest.");
} else {
// Drop the item at the player's location
player.getWorld().dropItemNaturally(player.getLocation(), overflow.get(0));
player.sendMessage(ChatColor.RED + "Your inventory and Ender Chest were full, so your armor was dropped on the ground.");
} }
}
}
// Destroy armor upon death etc. // Destroy armor upon death etc.

View File

@ -0,0 +1,54 @@
package me.nvus.nvus_prison_setup.Placeholders;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import org.bukkit.entity.Player;
public class CombinedPlaceholders extends PlaceholderExpansion {
private final PlaceholderManager placeholderManager;
public CombinedPlaceholders(PlaceholderManager placeholderManager) {
this.placeholderManager = placeholderManager;
}
@Override
public String getIdentifier() {
return "nvus";
}
@Override
public String getAuthor() {
return "never2nv";
}
@Override
public String getVersion() {
return "1.2";
}
@Override
public String onPlaceholderRequest(Player player, String identifier) {
if (player == null) {
return "";
}
switch (identifier) {
case "rank_current":
return placeholderManager.getCurrentRankName(player);
case "rank_next":
return placeholderManager.getNextRankName(player);
case "rank_cost":
double cost = placeholderManager.getNextRankCost(player);
return cost >= 0 ? String.format("$%.2f", cost) : "N/A";
case "gang_name":
return placeholderManager.getCurrentGangName(player);
case "gang_owner":
String gangName = placeholderManager.getCurrentGangName(player);
return placeholderManager.getGangOwnerName(gangName);
case "gang_members":
gangName = placeholderManager.getCurrentGangName(player);
return String.valueOf(placeholderManager.getGangMemberCount(gangName));
default:
return null;
}
}
}

View File

@ -36,12 +36,12 @@ public class GangPlaceholders extends PlaceholderExpansion {
String gangName = gangManager.getCurrentGangName(player.getUniqueId()); String gangName = gangManager.getCurrentGangName(player.getUniqueId());
if (gangName == null) { if (gangName == null) {
return " "; return "No Gang";
} }
GangInfo gangInfo = gangManager.getGangInfo(gangName); GangInfo gangInfo = gangManager.getGangInfo(gangName);
if (gangInfo == null) { if (gangInfo == null) {
return " "; return "Gang information could not be retrieved.";
} }
switch (identifier) { switch (identifier) {

View File

@ -4,10 +4,6 @@ import me.nvus.nvus_prison_setup.Gangs.GangInfo;
import me.nvus.nvus_prison_setup.Gangs.GangManager; import me.nvus.nvus_prison_setup.Gangs.GangManager;
import me.nvus.nvus_prison_setup.Ranks.Rank; import me.nvus.nvus_prison_setup.Ranks.Rank;
import me.nvus.nvus_prison_setup.Ranks.RankManager; import me.nvus.nvus_prison_setup.Ranks.RankManager;
import java.text.NumberFormat;
import java.util.Locale;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class PlaceholderManager { public class PlaceholderManager {
@ -43,19 +39,8 @@ public class PlaceholderManager {
return nextRank != null ? nextRank.getName() : "Max Rank"; return nextRank != null ? nextRank.getName() : "Max Rank";
} }
public String getNextRankCost(Player player) { public double getNextRankCost(Player player) {
Rank nextRank = rankManager.getNextRank(player); Rank nextRank = rankManager.getNextRank(player);
if (nextRank != null) { return nextRank != null ? nextRank.getCost() : -1;
double cost = nextRank.getCost();
// Using the US locale as an example for currency formatting
NumberFormat currencyFormat = NumberFormat.getCurrencyInstance(Locale.US);
return currencyFormat.format(cost);
} }
return "$0.00"; // or however you wish to indicate a null or zero value
}
// public double getNextRankCost(Player player) {
// Rank nextRank = rankManager.getNextRank(player);
// return nextRank != null ? nextRank.getCost() : -1;
// }
} }

View File

@ -5,8 +5,6 @@ import org.bukkit.entity.Player;
import me.nvus.nvus_prison_setup.Ranks.RankManager; import me.nvus.nvus_prison_setup.Ranks.RankManager;
import me.nvus.nvus_prison_setup.Ranks.Rank; import me.nvus.nvus_prison_setup.Ranks.Rank;
import java.text.DecimalFormat;
public class RankPlaceholders extends PlaceholderExpansion { public class RankPlaceholders extends PlaceholderExpansion {
private final RankManager rankManager; private final RankManager rankManager;
@ -47,16 +45,7 @@ public class RankPlaceholders extends PlaceholderExpansion {
case "rank_cost": case "rank_cost":
Rank rankForCost = rankManager.getNextRank(player); Rank rankForCost = rankManager.getNextRank(player);
if (rankForCost != null) { return rankForCost != null ? String.format("$%.2f", rankForCost.getCost()) : "N/A";
DecimalFormat decimalFormat = new DecimalFormat("$###,###.00");
return decimalFormat.format(rankForCost.getCost());
} else {
return "N/A";
}
// case "rank_cost":
// Rank rankForCost = rankManager.getNextRank(player);
// return rankForCost != null ? String.format("$%.2f", rankForCost.getCost()) : "N/A";
default: default:
return null; return null;

View File

@ -1,6 +1,5 @@
package me.nvus.nvus_prison_setup; package me.nvus.nvus_prison_setup;
import me.nvus.nvus_prison_setup.AutoSell.MultiplierManager;
import me.nvus.nvus_prison_setup.Configs.ConfigManager; import me.nvus.nvus_prison_setup.Configs.ConfigManager;
import me.nvus.nvus_prison_setup.Kit.KitManager; import me.nvus.nvus_prison_setup.Kit.KitManager;
import me.nvus.nvus_prison_setup.Configs.SettingsMenu; import me.nvus.nvus_prison_setup.Configs.SettingsMenu;
@ -49,9 +48,7 @@ import java.sql.Statement;
public final class PrisonSetup extends JavaPlugin { public final class PrisonSetup extends JavaPlugin {
private static PrisonSetup instance;
private ConfigManager configManager; private ConfigManager configManager;
private MultiplierManager multiplierManager;
private DatabaseManager dbManager; private DatabaseManager dbManager;
private GangManager gangManager; private GangManager gangManager;
@ -95,7 +92,7 @@ public final class PrisonSetup extends JavaPlugin {
// Check if Vault is installed, it's a hard dependency so disable plugin if not installed! // Check if Vault is installed, it's a hard dependency so disable plugin if not installed!
if (!setupEconomy()) { if (!setupEconomy()) {
getLogger().severe(String.format("[%s] - Disabled! Vault needs to be installed!", getDescription().getName())); getLogger().severe(String.format("[%s] - Disabled due to no Vault dependency found!", getDescription().getName()));
getServer().getPluginManager().disablePlugin(this); getServer().getPluginManager().disablePlugin(this);
return; return;
} }
@ -109,32 +106,22 @@ public final class PrisonSetup extends JavaPlugin {
this.getCommand("nvus").setExecutor(new CommandListener(this, configManager)); this.getCommand("nvus").setExecutor(new CommandListener(this, configManager));
// Gang Related... GANG, GANG #LOLOLOLOL // Gang Related... GANG, GANG #LOLOLOLOL
boolean gangsEnabled = configManager.getConfig("config.yml").getBoolean("PrisonerGangs", true);
if (gangsEnabled) {
this.getCommand("gang").setExecutor(new GangCommands(dbManager)); // Now correctly using initialized dbManager this.getCommand("gang").setExecutor(new GangCommands(dbManager)); // Now correctly using initialized dbManager
// Register the Gangs placeholder expansion // Register the Gangs placeholder expansion
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) { if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
// PlaceholderManager placeholderManager = new PlaceholderManager(gangManager, rankManager);
// new CombinedPlaceholders(placeholderManager).register();
new GangPlaceholders(gangManager).register(); new GangPlaceholders(gangManager).register();
} }
}
// Register the Auto Sell and Sell All Listeners // Register the Auto Sell and Sell All Listeners
boolean autoSellEnabled = configManager.getConfig("config.yml").getBoolean("AutoSell", true); boolean autoSellEnabled = configManager.getConfig("config.yml").getBoolean("AutoSell", true);
boolean sellAllEnabled = configManager.getConfig("config.yml").getBoolean("SellAll", true); boolean sellAllEnabled = configManager.getConfig("config.yml").getBoolean("SellAll", true);
boolean sellMultiplierEnabled = configManager.getConfig("config.yml").getBoolean("SellMultiplier", true); SellManager sellManager = new SellManager(configManager);
MultiplierManager multiplierManager = new MultiplierManager(this);
SellManager sellManager = new SellManager(configManager,multiplierManager);
this.getCommand("multiplier").setExecutor(multiplierManager);
this.getCommand("setprice").setExecutor(sellManager); this.getCommand("setprice").setExecutor(sellManager);
// if (sellMultiplierEnabled) {
// this.getCommand("multiplier").setExecutor(new MultiplierManager(this));
// }
// If they are true, register the commands. // If they are true, register the commands.
if (autoSellEnabled) { if (autoSellEnabled) {
// Register the autosell command. // Register the autosell command.
@ -275,8 +262,4 @@ public final class PrisonSetup extends JavaPlugin {
public GangManager getGangManager() { public GangManager getGangManager() {
return gangManager; return gangManager;
} }
public static PrisonSetup getInstance() {
return instance;
}
} }

View File

@ -9,8 +9,6 @@ import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import java.util.List; import java.util.List;
import java.text.DecimalFormat;
public class RankManager { public class RankManager {
@ -38,7 +36,7 @@ public class RankManager {
public boolean rankUp(Player player) { public boolean rankUp(Player player) {
Rank nextRank = getNextRank(player); Rank nextRank = getNextRank(player);
if (nextRank == null) { if (nextRank == null) {
player.sendMessage(ChatColor.RED + "You are already at the max rank!"); player.sendMessage(ChatColor.RED + "You are already at the highest rank!");
return false; return false;
} }
@ -48,50 +46,18 @@ public class RankManager {
if (response.transactionSuccess()) { if (response.transactionSuccess()) {
dbManager.updatePlayerRankData(player, nextRank); dbManager.updatePlayerRankData(player, nextRank);
executeRankCommands(player, nextRank.getCommands()); executeRankCommands(player, nextRank.getCommands());
// Success message can also be formatted if needed //player.sendMessage(ChatColor.GREEN + "Congratulations! You've been ranked up to " + nextRank.getName() + ".");
return true; return true;
} else { } else {
player.sendMessage(ChatColor.RED + "Transaction failed: " + response.errorMessage); player.sendMessage(ChatColor.RED + "Transaction failed: " + response.errorMessage);
return false; return false;
} }
} else { } else {
DecimalFormat decimalFormat = new DecimalFormat("$###,###,###.00"); player.sendMessage(ChatColor.RED + "You cannot afford to rank up. You need $" + nextRank.getCost() + ", but you only have $" + balance + ".");
String formattedCost = decimalFormat.format(nextRank.getCost());
String formattedBalance = decimalFormat.format(balance);
player.sendMessage(" ");
player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c&lYou cannot afford to rank up!"));
player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&6You need: &c" + formattedCost + "."));
player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&6But you only have: &a" + formattedBalance + "."));
player.sendMessage(" ");
return false; return false;
} }
} }
// public boolean rankUp(Player player) {
// Rank nextRank = getNextRank(player);
// if (nextRank == null) {
// player.sendMessage(ChatColor.RED + "You are already at the max rank!");
// return false;
// }
//
// double balance = economy.getBalance(player);
// if (balance >= nextRank.getCost()) {
// EconomyResponse response = economy.withdrawPlayer(player, nextRank.getCost());
// if (response.transactionSuccess()) {
// dbManager.updatePlayerRankData(player, nextRank);
// executeRankCommands(player, nextRank.getCommands());
// //player.sendMessage(ChatColor.GREEN + "Congratulations! You've been ranked up to " + nextRank.getName() + ".");
// return true;
// } else {
// player.sendMessage(ChatColor.RED + "Transaction failed: " + response.errorMessage);
// return false;
// }
// } else {
// player.sendMessage(ChatColor.RED + "You cannot afford to rank up. You need $" + nextRank.getCost() + ", but you only have $" + balance + ".");
// return false;
// }
// }
private void executeRankCommands(Player player, List<String> commands) { private void executeRankCommands(Player player, List<String> commands) {
if (commands == null || commands.isEmpty()) return; if (commands == null || commands.isEmpty()) return;
for (String command : commands) { for (String command : commands) {
@ -104,34 +70,17 @@ public class RankManager {
Rank currentRank = getCurrentRank(player); Rank currentRank = getCurrentRank(player);
// Assuming you have a method to get all ranks sorted by cost // Assuming you have a method to get all ranks sorted by cost
List<Rank> allRanks = dbManager.getAllRanksSorted(); List<Rank> allRanks = dbManager.getAllRanksSorted();
DecimalFormat decimalFormat = new DecimalFormat("$#,###.00");
for (Rank rank : allRanks) { for (Rank rank : allRanks) {
ranksMessage.append(ChatColor.YELLOW).append(rank.getName()) ranksMessage.append(ChatColor.YELLOW).append(rank.getName())
.append(ChatColor.WHITE).append(" - ") .append(ChatColor.WHITE).append(" - $")
.append(ChatColor.GREEN).append(decimalFormat.format(rank.getCost())).append("\n"); .append(ChatColor.GREEN).append(rank.getCost()).append("\n");
} }
ranksMessage.append(ChatColor.GOLD + "\n<EFBFBD> Your current rank: " + ChatColor.YELLOW + currentRank.getName()); ranksMessage.append(ChatColor.GOLD + "\nYour current rank: " + ChatColor.YELLOW + currentRank.getName());
double balance = economy.getBalance(player); double balance = economy.getBalance(player);
ranksMessage.append(ChatColor.GOLD + "\n<EFBFBD> Your balance: " + ChatColor.GREEN + decimalFormat.format(balance)); ranksMessage.append(ChatColor.GOLD + "\nYour balance: " + ChatColor.GREEN + "$" + balance);
return ranksMessage.toString(); return ranksMessage.toString();
} }
// public String getRanksDisplay(Player player) {
// StringBuilder ranksMessage = new StringBuilder(ChatColor.GOLD + "Available Ranks:\n");
// Rank currentRank = getCurrentRank(player);
// // Assuming you have a method to get all ranks sorted by cost
// List<Rank> allRanks = dbManager.getAllRanksSorted();
// for (Rank rank : allRanks) {
// ranksMessage.append(ChatColor.YELLOW).append(rank.getName())
// .append(ChatColor.WHITE).append(" - $")
// .append(ChatColor.GREEN).append(rank.getCost()).append("\n");
// }
// ranksMessage.append(ChatColor.GOLD + "\n<EFBFBD> Your current rank: " + ChatColor.YELLOW + currentRank.getName());
// double balance = economy.getBalance(player);
// ranksMessage.append(ChatColor.GOLD + "\n<EFBFBD> Your balance: " + ChatColor.GREEN + "$" + balance);
// return ranksMessage.toString();
// }
public void assignDefaultRank(Player player) { public void assignDefaultRank(Player player) {
dbManager.assignPlayerToDefaultRank(player); dbManager.assignPlayerToDefaultRank(player);

View File

@ -33,11 +33,6 @@ SellAll: true
# You can see material prices in the item_pricing.yml file or in-game using /sellprice <price> with an item in your hand. # You can see material prices in the item_pricing.yml file or in-game using /sellprice <price> with an item in your hand.
# Only players/prisoners with the permission nvus.prisoner can use the /sellprice command and autosell toggle. # Only players/prisoners with the permission nvus.prisoner can use the /sellprice command and autosell toggle.
# Should we allow the use of multipliers for selling items? ie 1.5x, 2x etc.
# These are admin commands that can be used by admins or other plugins like InfiniteVouchers etc. to give players a selling
# multiplier for a set amount of time. | /multiplier <player> 1.5 15m
SellMultiplier: True
######################################################################################## ########################################################################################
# ARMOR SETTINGS # # ARMOR SETTINGS #
######################################################################################## ########################################################################################
@ -120,17 +115,10 @@ TreeFarm: true
# PRISONER RANKS FEATURE # # PRISONER RANKS FEATURE #
######################################################################################## ########################################################################################
# Do you want to use the builand ht-in /rankup and /maxrankup commands to rank prisoners up? # Do you want to use the built-in /rankup and /maxrankup commands to rank prisoners up?
# Can configure the ranks in the ranks.yml file! # Can configure the ranks in the ranks.yml file!
PrisonerRanks: true PrisonerRanks: true
########################################################################################
# PRISONER GANGS FEATURE #
########################################################################################
# Do you want to enable the Prisoner Gangs feature?
PrisonerGangs: true
######################################################################################## ########################################################################################
# DATABASE SETTINGS # # DATABASE SETTINGS #
######################################################################################## ########################################################################################

View File

@ -59,9 +59,6 @@ commands:
usage: | usage: |
/autosell - Toggle auto selling all eligible items in your inventory. /autosell - Toggle auto selling all eligible items in your inventory.
aliases: [ automaticsell ] aliases: [ automaticsell ]
multiplier:
description: Apply a selling multiplier to a player.
usage: /multiplier <player> <multiplier> <duration>
setprice: setprice:
description: Set the price of the block being held in item_prices.yml. Set the price to 0 to remove it from the list! description: Set the price of the block being held in item_prices.yml. Set the price to 0 to remove it from the list!
usage: | usage: |
@ -88,9 +85,3 @@ permissions:
nvus.prisoner: nvus.prisoner:
description: Allows access to NVus Prison prisoner features ie AutoSwitch,AutoSell,Restricting Armor etc. description: Allows access to NVus Prison prisoner features ie AutoSwitch,AutoSell,Restricting Armor etc.
default: true default: true
nvus.sellall:
description: Allows access to /sellall command, independent of nvus.prisoner permission.
default: false
nvus.autosell:
description: Allows access to /autosell command toggle, independent of nvus.prisoner permission.
default: false