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:
parent
d51b1570b9
commit
6822f23dcc
2
pom.xml
2
pom.xml
|
@ -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>
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -54,16 +54,18 @@ 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")) {
|
||||||
|
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;
|
||||||
|
@ -74,25 +76,34 @@ 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 (command.getName().toLowerCase()) {
|
switch (label.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");
|
||||||
|
@ -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<>();
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue