Compare commits
No commits in common. "main" and "main" have entirely different histories.
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 |
2
pom.xml
2
pom.xml
|
@ -6,7 +6,7 @@
|
|||
|
||||
<groupId>me.NVus</groupId>
|
||||
<artifactId>NVus_Prison</artifactId>
|
||||
<version>1.1.8</version>
|
||||
<version>1.0.8</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>NVus_PrisonSetup</name>
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -19,10 +19,9 @@ public class AutoSellListener implements Listener {
|
|||
@EventHandler
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
// Added additional permission check
|
||||
if ((sellManager.isAutoSellEnabled(player)) ) {
|
||||
sellManager.sellItems(player);
|
||||
if (!player.hasPermission("nvus.prisoner") || !sellManager.isAutoSellEnabled(player)) {
|
||||
return;
|
||||
}
|
||||
sellManager.sellItems(player);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
|
@ -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.PrisonSetup;
|
||||
import me.nvus.nvus_prison_setup.AutoSell.MultiplierManager;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
|
@ -19,91 +18,58 @@ import java.io.IOException;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
|
||||
public class SellManager implements CommandExecutor {
|
||||
|
||||
private final HashMap<UUID, Boolean> autoSellStatus = new HashMap<>();
|
||||
private final HashMap<Material, Double> prices = new HashMap<>();
|
||||
|
||||
private final Map<UUID, MultiplierInfo> playerMultipliers = new ConcurrentHashMap<>();
|
||||
private final ConfigManager configManager;
|
||||
private final MultiplierManager multiplierManager;
|
||||
|
||||
public SellManager(ConfigManager configManager, MultiplierManager multiplierManager) {
|
||||
public SellManager(ConfigManager configManager) {
|
||||
this.configManager = configManager;
|
||||
this.multiplierManager = multiplierManager;
|
||||
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) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(ChatColor.RED + "Only players can use this command.");
|
||||
sender.sendMessage("Only players can use this command.");
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
|
||||
// Admin Commands:
|
||||
if ("setprice".equalsIgnoreCase(label)) {
|
||||
if (!player.hasPermission("nvus.admin")) {
|
||||
if ("setprice".equalsIgnoreCase(command.getName())) {
|
||||
if (player.hasPermission("nvus.admin")) {
|
||||
if (args.length != 1) {
|
||||
player.sendMessage(ChatColor.RED + "Usage: /setprice <price>");
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
double price = Double.parseDouble(args[0]);
|
||||
setPrice(player, price);
|
||||
} catch (NumberFormatException e) {
|
||||
player.sendMessage(ChatColor.RED + "Please provide a valid price.");
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + "You do not have permission to set prices.");
|
||||
return true;
|
||||
}
|
||||
if (args.length != 1) {
|
||||
player.sendMessage(ChatColor.RED + "Usage: /setprice <price>");
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
double price = Double.parseDouble(args[0]);
|
||||
setPrice(player, price);
|
||||
} catch (NumberFormatException e) {
|
||||
player.sendMessage(ChatColor.RED + "Please provide a valid price.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Player/Prisoner Commands:
|
||||
switch (label.toLowerCase()) {
|
||||
switch (command.getName().toLowerCase()) {
|
||||
case "autosell":
|
||||
if (player.hasPermission("nvus.prisoner") || player.hasPermission("nvus.autosell")) {
|
||||
toggleAutoSell(player);
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + "You do not have permission to use /autosell.");
|
||||
}
|
||||
toggleAutoSell(player);
|
||||
break;
|
||||
case "sellall":
|
||||
if (player.hasPermission("nvus.prisoner") || player.hasPermission("nvus.sellall")) {
|
||||
sellItems(player);
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + "You do not have permission to use /sellall.");
|
||||
}
|
||||
sellItems(player);
|
||||
break;
|
||||
default:
|
||||
// More commands in future? xD
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private void loadPrices() {
|
||||
FileConfiguration itemPricesConfig = configManager.getItemPricesConfig();
|
||||
ConfigurationSection pricesSection = itemPricesConfig.getConfigurationSection("Prices");
|
||||
|
@ -180,10 +146,10 @@ public class SellManager implements CommandExecutor {
|
|||
}
|
||||
|
||||
public void sellItems(Player player) {
|
||||
// if (player.hasPermission("nvus.prisoner") || player.hasPermission("nvus.sellall")) {
|
||||
// player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c&lYou do not have permission to use this command."));
|
||||
// return;
|
||||
// }
|
||||
if (!player.hasPermission("nvus.prisoner")) {
|
||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c&lYou do not have permission to use this command."));
|
||||
return;
|
||||
}
|
||||
|
||||
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) {
|
||||
Economy economy = PrisonSetup.getEconomy();
|
||||
double multiplier = multiplierManager.getPlayerMultiplier(player.getUniqueId());
|
||||
double finalAmount = amount * multiplier; // Apply the multiplier
|
||||
economy.depositPlayer(player, finalAmount);
|
||||
economy.depositPlayer(player, amount);
|
||||
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) {
|
||||
|
|
|
@ -41,21 +41,13 @@ public class SettingsMenu implements Listener {
|
|||
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(7, createToggleItem(Material.IRON_BARS , "Toggle PrisonerGangs", false));
|
||||
inv.setItem(8, createToggleItem(Material.BOOK, "Reload Configs", false));
|
||||
|
||||
// Second Row
|
||||
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(12, 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)));
|
||||
|
||||
|
||||
inv.setItem(11, createToggleItem(Material.OAK_SAPLING, "Toggle TreeFarm", config.getBoolean("TreeFarm", true)));
|
||||
|
||||
player.openInventory(inv);
|
||||
}
|
||||
|
@ -110,28 +102,10 @@ public class SettingsMenu implements Listener {
|
|||
toggleConfigOption(player, "AutoSwitch");
|
||||
} else if (displayName.contains("Toggle 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")) {
|
||||
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")) {
|
||||
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")) {
|
||||
reloadConfigs(player);
|
||||
}
|
||||
|
@ -165,7 +139,6 @@ public class SettingsMenu implements Listener {
|
|||
configManager.reloadConfig("auto_switch.yml");
|
||||
configManager.reloadConfig("banned_items.yml");
|
||||
configManager.reloadConfig("item_prices.yml");
|
||||
configManager.reloadConfig("ranks.yml");
|
||||
//configManager.saveConfig("config.yml");
|
||||
player.sendMessage(ChatColor.GREEN + "[NVus Prison] : Configuration files reloaded!");
|
||||
player.closeInventory();
|
||||
|
|
|
@ -9,7 +9,6 @@ import org.bukkit.inventory.ItemStack;
|
|||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -66,125 +65,44 @@ public class KitManager {
|
|||
|
||||
ItemStack item = new ItemStack(material);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
// Configure item meta (name, lore, enchantments)...
|
||||
|
||||
// Set the display name if available
|
||||
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")) {
|
||||
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);
|
||||
}
|
||||
|
||||
// Set enchantments if available
|
||||
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);
|
||||
|
||||
// Set item in specified quickbar slot, if available
|
||||
if (itemSpec.containsKey("slot")) {
|
||||
int slot = (Integer) itemSpec.get("slot");
|
||||
ItemStack existingItem = player.getInventory().getItem(slot);
|
||||
|
||||
if (existingItem != null && existingItem.getType() != Material.AIR && !isPrisonerKitItem(existingItem)) {
|
||||
moveItemToAvailableSlot(player, existingItem);
|
||||
}
|
||||
|
||||
player.getInventory().setItem(slot, item);
|
||||
player.getInventory().setItem((Integer) itemSpec.get("slot"), item);
|
||||
} else {
|
||||
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.");
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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.Kit.KitManager;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -92,8 +91,7 @@ public class KitListener implements Listener {
|
|||
|
||||
if (kitManager.isPrisonerKitItem(droppedItem)) {
|
||||
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)) {
|
||||
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!");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,8 +15,6 @@ import org.bukkit.inventory.ItemStack;
|
|||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.bukkit.inventory.meta.LeatherArmorMeta;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class PlayerArmor implements Listener {
|
||||
private final ConfigManager configManager;
|
||||
|
||||
|
@ -29,62 +27,46 @@ public class PlayerArmor implements Listener {
|
|||
Player player = event.getPlayer();
|
||||
if (player.hasPermission("nvus.prisoner") && configManager.getConfig("config.yml").getBoolean("PrisonerArmor")) {
|
||||
PlayerInventory inv = player.getInventory();
|
||||
ItemStack[] currentArmor = inv.getArmorContents();
|
||||
|
||||
for (int slot = 0; slot < currentArmor.length; slot++) {
|
||||
ItemStack armorPiece = currentArmor[slot];
|
||||
|
||||
// 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);
|
||||
inv.setArmorContents(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.sendMessage(ChatColor.translateAlternateColorCodes('&', "&cPer The Warden: &6&lYou have been equipped with standard issue prisoner armor!"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
if (!(event.getWhoClicked() instanceof Player)) return;
|
||||
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
|
||||
if (!player.hasPermission("nvus.prisoner")) return;
|
||||
|
||||
int slot = event.getSlot();
|
||||
// Correct the slot checks for the inventory interaction
|
||||
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 (event.getClickedInventory() != null && (event.getClickedInventory().getType() == InventoryType.PLAYER || event.getClickedInventory().getType() == InventoryType.CRAFTING)) {
|
||||
if (event.getSlotType() == InventoryType.SlotType.ARMOR || isArmorItem(event.getCurrentItem()) || isArmorItem(event.getCursor())) {
|
||||
|
||||
if (isArmorInteraction && (isPrisonerArmorItem(event.getCurrentItem()) || isPrisonerArmorItem(event.getCursor()))) {
|
||||
boolean restrictArmor = configManager.getConfig("config.yml").getBoolean("RestrictArmor");
|
||||
if (restrictArmor) {
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c&lPer The Warden: &c You cannot change your armor!"));
|
||||
boolean restrictArmor = configManager.getConfig("config.yml").getBoolean("RestrictArmor");
|
||||
if (restrictArmor) {
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c&lPer The Warden: &c You cannot change your armor!"));
|
||||
}
|
||||
// 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.
|
||||
private boolean isPrisonerArmorItem(ItemStack item) {
|
||||
if (item == null || !item.hasItemMeta()) return false;
|
||||
|
||||
String itemName = item.getItemMeta().getDisplayName();
|
||||
// Adjust these checks based on how you identify prisoner armor items.
|
||||
return itemName != null && (itemName.contains("Prisoner Boots") || itemName.contains("Prisoner Leggings")
|
||||
|| itemName.contains("Prisoner Chestplate") || itemName.contains("Prisoner Helmet"));
|
||||
private boolean isArmorItem(ItemStack item) {
|
||||
if (item == null) {
|
||||
return false;
|
||||
}
|
||||
Material type = item.getType();
|
||||
return type == Material.LEATHER_HELMET || type == Material.LEATHER_CHESTPLATE ||
|
||||
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) {
|
||||
|
@ -97,37 +79,4 @@ public class PlayerArmor implements Listener {
|
|||
}
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -12,11 +12,8 @@ import org.bukkit.event.Listener;
|
|||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.LeatherArmorMeta;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class PlayerSpawn implements Listener {
|
||||
private final ConfigManager configManager;
|
||||
|
||||
|
@ -58,71 +55,50 @@ public class PlayerSpawn implements Listener {
|
|||
}
|
||||
|
||||
private void equipPrisonerArmor(Player player) {
|
||||
handleNonPrisonerArmorItems(player); // Ensure non-prisoner armor is handled before equipping new armor
|
||||
|
||||
// Define and equip standard prisoner armor
|
||||
ItemStack[] standardPrisonerArmor = 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(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) {
|
||||
ItemStack item = new ItemStack(material);
|
||||
LeatherArmorMeta meta = (LeatherArmorMeta) item.getItemMeta();
|
||||
if (meta != null) {
|
||||
meta.setDisplayName(name);
|
||||
meta.setColor(Color.ORANGE); // Set the color for leather armor
|
||||
item.setItemMeta(meta);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
private void handleNonPrisonerArmorItems(Player player) {
|
||||
ItemStack[] armorContents = player.getInventory().getArmorContents();
|
||||
|
||||
for (int i = 0; i < armorContents.length; i++) {
|
||||
ItemStack armorPiece = armorContents[i];
|
||||
// Check if the armor piece is not part of the prisoner kit
|
||||
if (armorPiece != null && armorPiece.getType() != Material.AIR && !isPrisonerArmorItem(armorPiece)) {
|
||||
moveArmorToAvailableSlot(player, armorPiece);
|
||||
armorContents[i] = new ItemStack(Material.AIR); // Remove the non-prisoner armor from the armor slot
|
||||
}
|
||||
// Create Prisoner Helmet
|
||||
ItemStack leatherHelmetPrison = new ItemStack(Material.LEATHER_HELMET);
|
||||
LeatherArmorMeta helmetMeta = (LeatherArmorMeta) leatherHelmetPrison.getItemMeta();
|
||||
if (helmetMeta != null) {
|
||||
helmetMeta.setColor(Color.ORANGE);
|
||||
helmetMeta.setDisplayName(ChatColor.GOLD + "Prisoner Helmet");
|
||||
leatherHelmetPrison.setItemMeta(helmetMeta);
|
||||
}
|
||||
|
||||
// Update the player's armor contents after removals
|
||||
player.getInventory().setArmorContents(armorContents);
|
||||
}
|
||||
|
||||
private boolean isPrisonerArmorItem(ItemStack item) {
|
||||
if (item == null || !item.hasItemMeta()) return false;
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
String itemName = meta.getDisplayName();
|
||||
// Adjust the check based on your naming convention for prisoner armor
|
||||
return itemName != null && itemName.contains("Prisoner");
|
||||
}
|
||||
|
||||
private void moveArmorToAvailableSlot(Player player, ItemStack armorPiece) {
|
||||
// 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.");
|
||||
}
|
||||
// Create Prisoner Chestplate
|
||||
ItemStack leatherChestplatePrison = new ItemStack(Material.LEATHER_CHESTPLATE);
|
||||
LeatherArmorMeta chestplateMeta = (LeatherArmorMeta) leatherChestplatePrison.getItemMeta();
|
||||
if (chestplateMeta != null) {
|
||||
chestplateMeta.setColor(Color.ORANGE);
|
||||
chestplateMeta.setDisplayName(ChatColor.GOLD + "Prisoner Chestplate");
|
||||
leatherChestplatePrison.setItemMeta(chestplateMeta);
|
||||
}
|
||||
}
|
||||
|
||||
// Create Prisoner Leggings
|
||||
ItemStack leatherLeggingsPrison = new ItemStack(Material.LEATHER_LEGGINGS);
|
||||
LeatherArmorMeta leggingsMeta = (LeatherArmorMeta) leatherLeggingsPrison.getItemMeta();
|
||||
if (leggingsMeta != null) {
|
||||
leggingsMeta.setColor(Color.ORANGE);
|
||||
leggingsMeta.setDisplayName(ChatColor.GOLD + "Prisoner Leggings");
|
||||
leatherLeggingsPrison.setItemMeta(leggingsMeta);
|
||||
}
|
||||
|
||||
// Create Prisoner Boots
|
||||
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);
|
||||
}
|
||||
|
||||
// Equip Prisoner Armor
|
||||
player.getInventory().setHelmet(leatherHelmetPrison);
|
||||
player.getInventory().setChestplate(leatherChestplatePrison);
|
||||
player.getInventory().setLeggings(leatherLeggingsPrison);
|
||||
player.getInventory().setBoots(leatherBootsPrison);
|
||||
|
||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c&lPer The Warden: &6You've been given the default prisoner armor!"));
|
||||
}
|
||||
|
||||
|
||||
// Destroy armor upon death etc.
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -36,12 +36,12 @@ public class GangPlaceholders extends PlaceholderExpansion {
|
|||
|
||||
String gangName = gangManager.getCurrentGangName(player.getUniqueId());
|
||||
if (gangName == null) {
|
||||
return " ";
|
||||
return "No Gang";
|
||||
}
|
||||
|
||||
GangInfo gangInfo = gangManager.getGangInfo(gangName);
|
||||
if (gangInfo == null) {
|
||||
return " ";
|
||||
return "Gang information could not be retrieved.";
|
||||
}
|
||||
|
||||
switch (identifier) {
|
||||
|
|
|
@ -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.Ranks.Rank;
|
||||
import me.nvus.nvus_prison_setup.Ranks.RankManager;
|
||||
|
||||
import java.text.NumberFormat;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class PlaceholderManager {
|
||||
|
@ -43,19 +39,8 @@ public class PlaceholderManager {
|
|||
return nextRank != null ? nextRank.getName() : "Max Rank";
|
||||
}
|
||||
|
||||
public String getNextRankCost(Player player) {
|
||||
public double getNextRankCost(Player player) {
|
||||
Rank nextRank = rankManager.getNextRank(player);
|
||||
if (nextRank != null) {
|
||||
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
|
||||
return nextRank != null ? nextRank.getCost() : -1;
|
||||
}
|
||||
|
||||
// public double getNextRankCost(Player player) {
|
||||
// Rank nextRank = rankManager.getNextRank(player);
|
||||
// return nextRank != null ? nextRank.getCost() : -1;
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -5,8 +5,6 @@ import org.bukkit.entity.Player;
|
|||
import me.nvus.nvus_prison_setup.Ranks.RankManager;
|
||||
import me.nvus.nvus_prison_setup.Ranks.Rank;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
public class RankPlaceholders extends PlaceholderExpansion {
|
||||
|
||||
private final RankManager rankManager;
|
||||
|
@ -47,16 +45,7 @@ public class RankPlaceholders extends PlaceholderExpansion {
|
|||
|
||||
case "rank_cost":
|
||||
Rank rankForCost = rankManager.getNextRank(player);
|
||||
if (rankForCost != null) {
|
||||
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";
|
||||
return rankForCost != null ? String.format("$%.2f", rankForCost.getCost()) : "N/A";
|
||||
|
||||
default:
|
||||
return null;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
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.Kit.KitManager;
|
||||
import me.nvus.nvus_prison_setup.Configs.SettingsMenu;
|
||||
|
@ -49,9 +48,7 @@ import java.sql.Statement;
|
|||
|
||||
public final class PrisonSetup extends JavaPlugin {
|
||||
|
||||
private static PrisonSetup instance;
|
||||
private ConfigManager configManager;
|
||||
private MultiplierManager multiplierManager;
|
||||
private DatabaseManager dbManager;
|
||||
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!
|
||||
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);
|
||||
return;
|
||||
}
|
||||
|
@ -109,32 +106,22 @@ public final class PrisonSetup extends JavaPlugin {
|
|||
this.getCommand("nvus").setExecutor(new CommandListener(this, configManager));
|
||||
|
||||
// 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
|
||||
// Register the Gangs placeholder expansion
|
||||
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
|
||||
new GangPlaceholders(gangManager).register();
|
||||
}
|
||||
this.getCommand("gang").setExecutor(new GangCommands(dbManager)); // Now correctly using initialized dbManager
|
||||
// Register the Gangs placeholder expansion
|
||||
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
|
||||
// PlaceholderManager placeholderManager = new PlaceholderManager(gangManager, rankManager);
|
||||
// new CombinedPlaceholders(placeholderManager).register();
|
||||
new GangPlaceholders(gangManager).register();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Register the Auto Sell and Sell All Listeners
|
||||
boolean autoSellEnabled = configManager.getConfig("config.yml").getBoolean("AutoSell", true);
|
||||
boolean sellAllEnabled = configManager.getConfig("config.yml").getBoolean("SellAll", true);
|
||||
boolean sellMultiplierEnabled = configManager.getConfig("config.yml").getBoolean("SellMultiplier", true);
|
||||
|
||||
MultiplierManager multiplierManager = new MultiplierManager(this);
|
||||
SellManager sellManager = new SellManager(configManager,multiplierManager);
|
||||
this.getCommand("multiplier").setExecutor(multiplierManager);
|
||||
SellManager sellManager = new SellManager(configManager);
|
||||
this.getCommand("setprice").setExecutor(sellManager);
|
||||
|
||||
// if (sellMultiplierEnabled) {
|
||||
// this.getCommand("multiplier").setExecutor(new MultiplierManager(this));
|
||||
// }
|
||||
|
||||
// If they are true, register the commands.
|
||||
if (autoSellEnabled) {
|
||||
// Register the autosell command.
|
||||
|
@ -275,8 +262,4 @@ public final class PrisonSetup extends JavaPlugin {
|
|||
public GangManager getGangManager() {
|
||||
return gangManager;
|
||||
}
|
||||
|
||||
public static PrisonSetup getInstance() {
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,8 +9,6 @@ import org.bukkit.entity.Player;
|
|||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.List;
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
|
||||
public class RankManager {
|
||||
|
||||
|
@ -38,7 +36,7 @@ public class RankManager {
|
|||
public boolean rankUp(Player player) {
|
||||
Rank nextRank = getNextRank(player);
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -48,50 +46,18 @@ public class RankManager {
|
|||
if (response.transactionSuccess()) {
|
||||
dbManager.updatePlayerRankData(player, nextRank);
|
||||
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;
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + "Transaction failed: " + response.errorMessage);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
DecimalFormat decimalFormat = new DecimalFormat("$###,###,###.00");
|
||||
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(" ");
|
||||
player.sendMessage(ChatColor.RED + "You cannot afford to rank up. You need $" + nextRank.getCost() + ", but you only have $" + balance + ".");
|
||||
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) {
|
||||
if (commands == null || commands.isEmpty()) return;
|
||||
for (String command : commands) {
|
||||
|
@ -104,34 +70,17 @@ public class RankManager {
|
|||
Rank currentRank = getCurrentRank(player);
|
||||
// Assuming you have a method to get all ranks sorted by cost
|
||||
List<Rank> allRanks = dbManager.getAllRanksSorted();
|
||||
DecimalFormat decimalFormat = new DecimalFormat("$#,###.00");
|
||||
for (Rank rank : allRanks) {
|
||||
ranksMessage.append(ChatColor.YELLOW).append(rank.getName())
|
||||
.append(ChatColor.WHITE).append(" - ")
|
||||
.append(ChatColor.GREEN).append(decimalFormat.format(rank.getCost())).append("\n");
|
||||
.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());
|
||||
ranksMessage.append(ChatColor.GOLD + "\nYour current rank: " + ChatColor.YELLOW + currentRank.getName());
|
||||
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();
|
||||
}
|
||||
|
||||
// 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) {
|
||||
dbManager.assignPlayerToDefaultRank(player);
|
||||
|
|
|
@ -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.
|
||||
# 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 #
|
||||
########################################################################################
|
||||
|
@ -120,17 +115,10 @@ TreeFarm: true
|
|||
# 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!
|
||||
PrisonerRanks: true
|
||||
|
||||
########################################################################################
|
||||
# PRISONER GANGS FEATURE #
|
||||
########################################################################################
|
||||
|
||||
# Do you want to enable the Prisoner Gangs feature?
|
||||
PrisonerGangs: true
|
||||
|
||||
########################################################################################
|
||||
# DATABASE SETTINGS #
|
||||
########################################################################################
|
||||
|
|
|
@ -59,9 +59,6 @@ commands:
|
|||
usage: |
|
||||
/autosell - Toggle auto selling all eligible items in your inventory.
|
||||
aliases: [ automaticsell ]
|
||||
multiplier:
|
||||
description: Apply a selling multiplier to a player.
|
||||
usage: /multiplier <player> <multiplier> <duration>
|
||||
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!
|
||||
usage: |
|
||||
|
@ -88,9 +85,3 @@ permissions:
|
|||
nvus.prisoner:
|
||||
description: Allows access to NVus Prison prisoner features ie AutoSwitch,AutoSell,Restricting Armor etc.
|
||||
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
|
Loading…
Reference in New Issue