From 6822f23dcc425a96d5970410b3d2bd9660b0b18d Mon Sep 17 00:00:00 2001 From: WildInterloper <156627888+WildInterloper@users.noreply.github.com> Date: Thu, 28 Mar 2024 03:47:00 -0400 Subject: [PATCH] 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! --- pom.xml | 2 +- .../AutoSell/Listeners/AutoSellListener.java | 9 ++- .../AutoSell/SellManager.java | 55 +++++++++++-------- src/main/resources/config.yml | 2 +- 4 files changed, 39 insertions(+), 29 deletions(-) diff --git a/pom.xml b/pom.xml index b12a98f..0023df8 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ me.NVus NVus_Prison - 1.1.2 + 1.1.6 jar NVus_PrisonSetup diff --git a/src/main/java/me/nvus/nvus_prison_setup/AutoSell/Listeners/AutoSellListener.java b/src/main/java/me/nvus/nvus_prison_setup/AutoSell/Listeners/AutoSellListener.java index c4ad540..d6184a7 100644 --- a/src/main/java/me/nvus/nvus_prison_setup/AutoSell/Listeners/AutoSellListener.java +++ b/src/main/java/me/nvus/nvus_prison_setup/AutoSell/Listeners/AutoSellListener.java @@ -1,7 +1,6 @@ package me.nvus.nvus_prison_setup.AutoSell.Listeners; import me.nvus.nvus_prison_setup.AutoSell.SellManager; -import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.event.EventHandler; @@ -20,10 +19,10 @@ public class AutoSellListener implements Listener { @EventHandler public void onBlockBreak(BlockBreakEvent event) { Player player = event.getPlayer(); - if (!player.hasPermission("nvus.prisoner") || !player.hasPermission("nvus.autosell") || !sellManager.isAutoSellEnabled(player)) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c&lYou do not have permission to use this command.")); - return; + // Added additional permission check + if ((sellManager.isAutoSellEnabled(player)) ) { + sellManager.sellItems(player); } - sellManager.sellItems(player); } + } diff --git a/src/main/java/me/nvus/nvus_prison_setup/AutoSell/SellManager.java b/src/main/java/me/nvus/nvus_prison_setup/AutoSell/SellManager.java index 5de79e8..45396fd 100644 --- a/src/main/java/me/nvus/nvus_prison_setup/AutoSell/SellManager.java +++ b/src/main/java/me/nvus/nvus_prison_setup/AutoSell/SellManager.java @@ -54,45 +54,56 @@ public class SellManager implements CommandExecutor { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (!(sender instanceof Player)) { - sender.sendMessage("Only players can use this command."); + sender.sendMessage(ChatColor.RED + "Only players can use this command."); return true; } - Player player = (Player) sender; // Admin Commands: - if ("setprice".equalsIgnoreCase(command.getName())) { - if (player.hasPermission("nvus.admin")) { - if (args.length != 1) { - player.sendMessage(ChatColor.RED + "Usage: /setprice "); - 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 { + if ("setprice".equalsIgnoreCase(label)) { + if (!player.hasPermission("nvus.admin")) { player.sendMessage(ChatColor.RED + "You do not have permission to set prices."); + return true; + } + if (args.length != 1) { + player.sendMessage(ChatColor.RED + "Usage: /setprice "); + 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 (command.getName().toLowerCase()) { + switch (label.toLowerCase()) { 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; 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; + default: + // More commands in future? xD + return false; } return true; } + private void loadPrices() { FileConfiguration itemPricesConfig = configManager.getItemPricesConfig(); ConfigurationSection pricesSection = itemPricesConfig.getConfigurationSection("Prices"); @@ -169,10 +180,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.hasPermission("nvus.sellall")) { +// player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c&lYou do not have permission to use this command.")); +// return; +// } Map soldItems = new HashMap<>(); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 3ae6ddc..40fe328 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -120,7 +120,7 @@ TreeFarm: true # 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! PrisonerRanks: true