1.1.6 - Added money boosters/selling multiplier commands which can be used with voucher plugins! Also added additional permissions (optional) for /autosell and /sellall to allow non-prisoners to still use thoe features!

This commit is contained in:
WildInterloper 2024-03-28 03:47:00 -04:00
parent d51b1570b9
commit 6822f23dcc
4 changed files with 39 additions and 29 deletions

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.2</version> <version>1.1.6</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>NVus_PrisonSetup</name> <name>NVus_PrisonSetup</name>

View File

@ -1,7 +1,6 @@
package me.nvus.nvus_prison_setup.AutoSell.Listeners; package me.nvus.nvus_prison_setup.AutoSell.Listeners;
import me.nvus.nvus_prison_setup.AutoSell.SellManager; import me.nvus.nvus_prison_setup.AutoSell.SellManager;
import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -20,10 +19,10 @@ 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();
if (!player.hasPermission("nvus.prisoner") || !player.hasPermission("nvus.autosell") || !sellManager.isAutoSellEnabled(player)) { // Added additional permission check
player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c&lYou do not have permission to use this command.")); if ((sellManager.isAutoSellEnabled(player)) ) {
return; sellManager.sellItems(player);
} }
sellManager.sellItems(player);
} }
} }

View File

@ -54,45 +54,56 @@ public class SellManager implements CommandExecutor {
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("Only players can use this command."); sender.sendMessage(ChatColor.RED + "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(command.getName())) { if ("setprice".equalsIgnoreCase(label)) {
if (player.hasPermission("nvus.admin")) { 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."); 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; return true;
} }
// Player/Prisoner Commands: // Player/Prisoner Commands:
switch (command.getName().toLowerCase()) { switch (label.toLowerCase()) {
case "autosell": case "autosell":
toggleAutoSell(player); if (player.hasPermission("nvus.prisoner") || player.hasPermission("nvus.autosell")) {
toggleAutoSell(player);
} else {
player.sendMessage(ChatColor.RED + "You do not have permission to use /autosell.");
}
break; break;
case "sellall": case "sellall":
sellItems(player); if (player.hasPermission("nvus.prisoner") || player.hasPermission("nvus.sellall")) {
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");
@ -169,10 +180,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.hasPermission("nvus.sellall")) {
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<>();

View File

@ -120,7 +120,7 @@ TreeFarm: true
# PRISONER RANKS FEATURE # # PRISONER RANKS FEATURE #
######################################################################################## ########################################################################################
# Do you want to use the built-in /rankup and /maxrankup commands to rank prisoners up? # Do you want to use the builand ht-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