1.1.0 - Added toggle for Gangs upon startup and added the toggle to settings menu!
This commit is contained in:
parent
e105f967d1
commit
b1d829a132
2
pom.xml
2
pom.xml
|
@ -6,7 +6,7 @@
|
|||
|
||||
<groupId>me.NVus</groupId>
|
||||
<artifactId>NVus_Prison</artifactId>
|
||||
<version>1.0.8</version>
|
||||
<version>1.1.0</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>NVus_PrisonSetup</name>
|
||||
|
|
|
@ -41,13 +41,21 @@ 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(11, createToggleItem(Material.OAK_SAPLING, "Toggle TreeFarm", config.getBoolean("TreeFarm", 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)));
|
||||
|
||||
|
||||
|
||||
player.openInventory(inv);
|
||||
}
|
||||
|
@ -102,10 +110,28 @@ 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);
|
||||
}
|
||||
|
@ -139,6 +165,7 @@ 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();
|
||||
|
|
|
@ -2,6 +2,7 @@ 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;
|
||||
|
@ -91,7 +92,8 @@ public class KitListener implements Listener {
|
|||
|
||||
if (kitManager.isPrisonerKitItem(droppedItem)) {
|
||||
event.setCancelled(true);
|
||||
player.sendMessage("§c&lPER THE WARDEN: You cannot drop your prisoner kit items!");
|
||||
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!");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -114,7 +116,7 @@ public class KitListener implements Listener {
|
|||
|
||||
if (kitManager.isPrisonerKitItem(clickedItem)) {
|
||||
event.setCancelled(true);
|
||||
player.sendMessage("§cPER THE WARDEN: You cannot move your prisoner kit items!");
|
||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', "§c&lPER THE WARDEN: You cannot move your prisoner kit items!"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -52,6 +52,7 @@ public class PlayerArmor implements Listener {
|
|||
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.
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,54 +0,0 @@
|
|||
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 "No Gang";
|
||||
return " ";
|
||||
}
|
||||
|
||||
GangInfo gangInfo = gangManager.getGangInfo(gangName);
|
||||
if (gangInfo == null) {
|
||||
return "Gang information could not be retrieved.";
|
||||
return " ";
|
||||
}
|
||||
|
||||
switch (identifier) {
|
||||
|
|
|
@ -4,6 +4,10 @@ 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 {
|
||||
|
@ -39,8 +43,19 @@ public class PlaceholderManager {
|
|||
return nextRank != null ? nextRank.getName() : "Max Rank";
|
||||
}
|
||||
|
||||
public double getNextRankCost(Player player) {
|
||||
public String getNextRankCost(Player player) {
|
||||
Rank nextRank = rankManager.getNextRank(player);
|
||||
return nextRank != null ? nextRank.getCost() : -1;
|
||||
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
|
||||
}
|
||||
|
||||
// public double getNextRankCost(Player player) {
|
||||
// Rank nextRank = rankManager.getNextRank(player);
|
||||
// return nextRank != null ? nextRank.getCost() : -1;
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -5,6 +5,8 @@ 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;
|
||||
|
@ -45,7 +47,16 @@ public class RankPlaceholders extends PlaceholderExpansion {
|
|||
|
||||
case "rank_cost":
|
||||
Rank rankForCost = rankManager.getNextRank(player);
|
||||
return rankForCost != null ? String.format("$%.2f", rankForCost.getCost()) : "N/A";
|
||||
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";
|
||||
|
||||
default:
|
||||
return null;
|
||||
|
|
|
@ -92,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 due to no Vault dependency found!", getDescription().getName()));
|
||||
getLogger().severe(String.format("[%s] - Disabled! Vault needs to be installed!", getDescription().getName()));
|
||||
getServer().getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
}
|
||||
|
@ -106,16 +106,18 @@ public final class PrisonSetup extends JavaPlugin {
|
|||
this.getCommand("nvus").setExecutor(new CommandListener(this, configManager));
|
||||
|
||||
// Gang Related... GANG, GANG #LOLOLOLOL
|
||||
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();
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// 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);
|
||||
|
|
|
@ -9,6 +9,8 @@ import org.bukkit.entity.Player;
|
|||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.List;
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
|
||||
public class RankManager {
|
||||
|
||||
|
@ -36,7 +38,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 highest rank!");
|
||||
player.sendMessage(ChatColor.RED + "You are already at the max rank!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -46,18 +48,50 @@ public class RankManager {
|
|||
if (response.transactionSuccess()) {
|
||||
dbManager.updatePlayerRankData(player, nextRank);
|
||||
executeRankCommands(player, nextRank.getCommands());
|
||||
//player.sendMessage(ChatColor.GREEN + "Congratulations! You've been ranked up to " + nextRank.getName() + ".");
|
||||
// Success message can also be formatted if needed
|
||||
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 + ".");
|
||||
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(" ");
|
||||
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) {
|
||||
|
@ -70,17 +104,34 @@ 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(rank.getCost()).append("\n");
|
||||
.append(ChatColor.WHITE).append(" - ")
|
||||
.append(ChatColor.GREEN).append(decimalFormat.format(rank.getCost())).append("\n");
|
||||
}
|
||||
ranksMessage.append(ChatColor.GOLD + "\nYour current rank: " + ChatColor.YELLOW + currentRank.getName());
|
||||
ranksMessage.append(ChatColor.GOLD + "\n<EFBFBD> Your current rank: " + ChatColor.YELLOW + currentRank.getName());
|
||||
double balance = economy.getBalance(player);
|
||||
ranksMessage.append(ChatColor.GOLD + "\nYour balance: " + ChatColor.GREEN + "$" + balance);
|
||||
ranksMessage.append(ChatColor.GOLD + "\n<EFBFBD> Your balance: " + ChatColor.GREEN + decimalFormat.format(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);
|
||||
|
|
|
@ -119,6 +119,13 @@ TreeFarm: true
|
|||
# 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 #
|
||||
########################################################################################
|
||||
|
|
Loading…
Reference in New Issue