From 6ad165b19b7fbdbfc0d71bbace4c5f0fc9114456 Mon Sep 17 00:00:00 2001 From: sandtechnology Date: Sun, 5 Apr 2020 13:21:36 +0800 Subject: [PATCH] Add several options about creative mode Former-commit-id: 49a9a35a66187e29078af36dad61db740fb0d29b --- .../quickshop/Listeners/BlockListener.java | 17 +- .../org/maxgamer/quickshop/QuickShop.java | 16 +- .../maxgamer/quickshop/Shop/ShopManager.java | 97 ++-- .../org/maxgamer/quickshop/Util/MsgUtil.java | 439 +++++++++--------- src/main/resources/config.yml | 9 +- .../resources/lang-original/messages.json | 6 +- 6 files changed, 303 insertions(+), 281 deletions(-) diff --git a/src/main/java/org/maxgamer/quickshop/Listeners/BlockListener.java b/src/main/java/org/maxgamer/quickshop/Listeners/BlockListener.java index 4f5c75b5b..36fee40ad 100644 --- a/src/main/java/org/maxgamer/quickshop/Listeners/BlockListener.java +++ b/src/main/java/org/maxgamer/quickshop/Listeners/BlockListener.java @@ -83,6 +83,11 @@ public class BlockListener extends ProtectionListenerBase implements Listener { if (p.getGameMode() == GameMode.CREATIVE && !p.getUniqueId().equals(shop.getOwner())) { // Check SuperTool if (p.getInventory().getItemInMainHand().getType() == Material.GOLDEN_AXE) { + if(getPlugin().getConfig().getBoolean("shop.disable-super-tool")){ + e.setCancelled(true); + p.sendMessage(MsgUtil.getMessage("supertool-is-disabled", p)); + return; + } p.sendMessage(MsgUtil.getMessage("break-shop-use-supertool", p)); return; } @@ -135,6 +140,11 @@ public class BlockListener extends ProtectionListenerBase implements Listener { if (p.getGameMode() == GameMode.CREATIVE && !p.getUniqueId().equals(shop.getOwner())) { // Check SuperTool if (p.getInventory().getItemInMainHand().getType() == Material.GOLDEN_AXE) { + if(getPlugin().getConfig().getBoolean("shop.disable-super-tool")){ + e.setCancelled(true); + p.sendMessage(MsgUtil.getMessage("supertool-is-disabled", p)); + return; + } p.sendMessage(MsgUtil.getMessage("break-shop-use-supertool", p)); shop.delete(); return; @@ -145,10 +155,11 @@ public class BlockListener extends ProtectionListenerBase implements Listener { "no-creative-break", p, MsgUtil.getItemi18n(Material.GOLDEN_AXE.name()))); } //Allow Shop owner break the shop sign(for sign replacement) - if(!p.getUniqueId().equals(shop.getOwner())){ - Util.debugLog("Cannot break the sign."); - e.setCancelled(true); + if(getPlugin().getConfig().getBoolean("shop.allow-owner-break-shop-sign")&&p.getUniqueId().equals(shop.getOwner())){ + return; } + Util.debugLog("Cannot break the sign."); + e.setCancelled(true); } } diff --git a/src/main/java/org/maxgamer/quickshop/QuickShop.java b/src/main/java/org/maxgamer/quickshop/QuickShop.java index c7b48a664..3f89bd1a5 100644 --- a/src/main/java/org/maxgamer/quickshop/QuickShop.java +++ b/src/main/java/org/maxgamer/quickshop/QuickShop.java @@ -19,12 +19,6 @@ package org.maxgamer.quickshop; -import java.io.File; -import java.io.IOException; -import java.lang.reflect.Field; -import java.nio.file.Files; -import java.util.*; -import java.util.Map.Entry; import lombok.Getter; import me.minebuilders.clearlag.Clearlag; import me.minebuilders.clearlag.listeners.ItemMergeListener; @@ -61,6 +55,13 @@ import org.maxgamer.quickshop.Util.Timer; import org.maxgamer.quickshop.Util.ServerForkWrapper.SpigotWrapper; import org.maxgamer.quickshop.Watcher.*; +import java.io.File; +import java.io.IOException; +import java.lang.reflect.Field; +import java.nio.file.Files; +import java.util.*; +import java.util.Map.Entry; + public class QuickShop extends JavaPlugin { @@ -1540,6 +1541,9 @@ public class QuickShop extends JavaPlugin { if (selectedVersion == 92) { getConfig().set("send-display-item-protection-alert", false); getConfig().set("send-shop-protection-alert", false); + getConfig().set("disable-creative-mode-trading",false); + getConfig().set("disable-super-tool",false); + getConfig().set("allow-owner-break-shop-sign",true); getConfig().set("config-version", 93); selectedVersion = 93; } diff --git a/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java b/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java index 487b50ec6..ba4c2e510 100644 --- a/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java +++ b/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java @@ -537,18 +537,7 @@ public class ShopManager { } private void actionBuy(@NotNull Player p, @NotNull Economy eco, @NotNull HashMap actions2, @NotNull Info info, @NotNull String message, @NotNull Shop shop, int amount) { - if (plugin.getEconomy() == null) { - p.sendMessage("Error: Economy system not loaded, type /qs main command to get details."); - return; - } - if (!Util.canBeShop(info.getLocation().getBlock())) { - p.sendMessage(MsgUtil.getMessage("chest-was-removed", p)); - return; - } - if (info.hasChanged(shop)) { - p.sendMessage(MsgUtil.getMessage("shop-has-changed", p)); - return; - } + if (shopIsNotValid(p, info, shop)){ return;} int space = shop.getRemainingSpace(); if (space == -1) { space = 10000; @@ -573,22 +562,8 @@ public class ShopManager { return; // Cancelled } // Money handling - double tax = plugin.getConfig().getDouble("tax"); + double tax = getTax(shop,p); double total = amount * shop.getPrice(); - if (QuickShop.getPermissionManager().hasPermission(p, "quickshop.tax")) { - tax = 0; - Util.debugLog("Disable the Tax for player " + p.getName() + " cause they have permission quickshop.tax"); - } - if (tax >= 1.0) { - plugin.getLogger().warning("Disable tax due to is invalid, it should be in 0.0-1.0 (current value is " + tax + ")"); - tax = 0; - } - if (tax < 0) { - tax = 0; // Tax was disabled. - } - if (shop.getModerator().isModerator(p.getUniqueId())) { - tax = 0; // Is staff or owner, so we won't will take them tax - } boolean shouldPayOwner = !shop.isUnlimited() || (plugin.getConfig().getBoolean("shop.pay-unlimited-shop-owners") && shop.isUnlimited()); if (shouldPayOwner) { @@ -629,7 +604,24 @@ public class ShopManager { shop.setSignText(); // Update the signs count } - @SuppressWarnings("deprecation") + private double getTax(Shop shop,Player p){ + double tax = plugin.getConfig().getDouble("tax"); + if (QuickShop.getPermissionManager().hasPermission(p, "quickshop.tax")) { + tax = 0; + Util.debugLog("Disable the Tax for player " + p.getName() + " cause they have permission quickshop.tax"); + } + if (tax >= 1.0) { + plugin.getLogger().warning("Disable tax due to is invalid, it should be in 0.0-1.0 (current value is " + tax + ")"); + tax = 0; + } + if (tax < 0) { + tax = 0; // Tax was disabled. + } + if (shop.getModerator().isModerator(p.getUniqueId())) { + tax = 0; // Is staff or owner, so we won't will take them tax + } + return tax; + } private void actionCreate(@NotNull Player p, @NotNull HashMap actions2, @NotNull Info info, @NotNull String message, boolean bypassProtectionChecks) { if (plugin.getEconomy() == null) { @@ -811,18 +803,7 @@ public class ShopManager { } private void actionSell(@NotNull Player p, @NotNull Economy eco, @NotNull HashMap actions2, @NotNull Info info, @NotNull String message, @NotNull Shop shop, int amount) { - if (plugin.getEconomy() == null) { - p.sendMessage("Error: Economy system not loaded, type /qs main command to get details."); - return; - } - if (!Util.canBeShop(info.getLocation().getBlock())) { - p.sendMessage(MsgUtil.getMessage("chest-was-removed", p)); - return; - } - if (info.hasChanged(shop)) { - p.sendMessage(MsgUtil.getMessage("shop-has-changed", p)); - return; - } + if (shopIsNotValid(p, info, shop)) {return;} int stock = shop.getRemainingStock(); if (stock == -1) { stock = 10000; @@ -845,19 +826,10 @@ public class ShopManager { if (Util.fireCancellableEvent(e)) { return; // Cancelled } + double tax = getTax(shop,p); // Money handling - double tax = plugin.getConfig().getDouble("tax"); double total = amount * shop.getPrice(); - if (QuickShop.getPermissionManager().hasPermission(p, "quickshop.tax")) { - tax = 0; - Util.debugLog("Disable the Tax for player " + p.getName() + " cause they have permission quickshop.tax"); - } - if (tax < 0) { - tax = 0; // Tax was disabled. - } - if (shop.getModerator().isModerator(p.getUniqueId())) { - tax = 0; // Is staff or owner, so we won't will take them tax - } + boolean successA = eco.withdraw(p.getUniqueId(), total); // Withdraw owner's money if (!successA) { @@ -898,6 +870,22 @@ public class ShopManager { Bukkit.getPluginManager().callEvent(se); } + private boolean shopIsNotValid(@NotNull Player p, @NotNull Info info, @NotNull Shop shop) { + if (plugin.getEconomy() == null) { + p.sendMessage("Error: Economy system not loaded, type /qs main command to get details."); + return true; + } + if (!Util.canBeShop(info.getLocation().getBlock())) { + p.sendMessage(MsgUtil.getMessage("chest-was-removed", p)); + return true; + } + if (info.hasChanged(shop)) { + p.sendMessage(MsgUtil.getMessage("shop-has-changed", p)); + return true; + } + return false; + } + private void actionTrade(@NotNull Player p, @NotNull HashMap actions, @NotNull Info info, @NotNull String message) { if (plugin.getEconomy() == null) { p.sendMessage("Error: Economy system not loaded, type /qs main command to get details."); @@ -916,6 +904,10 @@ public class ShopManager { p.sendMessage(MsgUtil.getMessage("chest-was-removed", p)); return; } + if(p.getGameMode()==GameMode.CREATIVE&&plugin.getConfig().getBoolean("shop.disable-creative-mode-trading")){ + p.sendMessage(MsgUtil.getMessage("trading-in-creative-mode-is-disabled",p)); + return; + } int amount; if (info.hasChanged(shop)) { p.sendMessage(MsgUtil.getMessage("shop-has-changed", p)); @@ -998,7 +990,6 @@ public class ShopManager { if (!shop.isUnlimited() && shopHaveItems < 1) { // but also the shop's stock is 0 p.sendMessage(MsgUtil.getMessage("shop-stock-too-low", p, "" + shop.getRemainingStock(), Util.getItemStackName(shop.getItem()))); - return; } else { // when if player's inventory is full if (invHaveSpaces == 0) { @@ -1006,8 +997,8 @@ public class ShopManager { return; } p.sendMessage(MsgUtil.getMessage("you-cant-afford-to-buy", p, Objects.requireNonNull(format(price)), Objects.requireNonNull(format(balance)))); - return; } + return; } } else { // instead of output cancelled message, just let player know that there should be positive diff --git a/src/main/java/org/maxgamer/quickshop/Util/MsgUtil.java b/src/main/java/org/maxgamer/quickshop/Util/MsgUtil.java index 0c46ed761..5df496c17 100644 --- a/src/main/java/org/maxgamer/quickshop/Util/MsgUtil.java +++ b/src/main/java/org/maxgamer/quickshop/Util/MsgUtil.java @@ -68,7 +68,7 @@ public class MsgUtil { private static final QuickShop plugin = QuickShop.instance; private static final DecimalFormat decimalFormat = - new DecimalFormat(Objects.requireNonNull(plugin.getConfig().getString("decimal-format"))); + new DecimalFormat(Objects.requireNonNull(plugin.getConfig().getString("decimal-format"))); private static YamlConfiguration enchi18n; @@ -89,8 +89,8 @@ public class MsgUtil { */ public static void clean() { plugin - .getLogger() - .info("Cleaning purchase messages from the database that are over a week old..."); + .getLogger() + .info("Cleaning purchase messages from the database that are over a week old..."); // 604800,000 msec = 1 week. long weekAgo = System.currentTimeMillis() - 604800000; plugin.getDatabaseHelper().cleanMessage(weekAgo); @@ -135,10 +135,10 @@ public class MsgUtil { @SneakyThrows public static void sendItemholochat( - @NotNull Player player, - @NotNull String left, - @NotNull ItemStack itemStack, - @NotNull String right) { + @NotNull Player player, + @NotNull String left, + @NotNull ItemStack itemStack, + @NotNull String right) { String json = ItemNMS.saveJsonfromNMS(itemStack); if (json == null) { return; @@ -176,13 +176,13 @@ public class MsgUtil { /** * getMessage in messages.yml * - * @param loc location + * @param loc location * @param player The sender will send the message to - * @param args args + * @param args args * @return message */ public static String getMessageOfflinePlayer( - @NotNull String loc, @Nullable OfflinePlayer player, @NotNull String... args) { + @NotNull String loc, @Nullable OfflinePlayer player, @NotNull String... args) { try { Optional raw = messagei18n.getString(loc); if (!raw.isPresent()) { @@ -206,7 +206,7 @@ public class MsgUtil { /** * Replace args in raw to args * - * @param raw text + * @param raw text * @param args args * @return filled text */ @@ -243,15 +243,15 @@ public class MsgUtil { IFile nJson; if (plugin.getResource("lang/" + languageCode + "/messages.json") == null) { nJson = - new JSONFile( - plugin, new File(plugin.getDataFolder(), "messages.json"), "lang-original/messages.json", true); + new JSONFile( + plugin, new File(plugin.getDataFolder(), "messages.json"), "lang-original/messages.json", true); } else { nJson = - new JSONFile( - plugin, - new File(plugin.getDataFolder(), "messages.json"), - "lang/" + languageCode + "/messages.json", - true); + new JSONFile( + plugin, + new File(plugin.getDataFolder(), "messages.json"), + "lang/" + languageCode + "/messages.json", + true); } nJson.create(); @@ -266,7 +266,7 @@ public class MsgUtil { nJson.save(); try { Files.move( - oldMsgFile.toPath(), new File(plugin.getDataFolder(), "messages.yml.bak").toPath()); + oldMsgFile.toPath(), new File(plugin.getDataFolder(), "messages.yml.bak").toPath()); } catch (IOException ignore) { } if (oldMsgFile.exists()) { @@ -324,8 +324,8 @@ public class MsgUtil { enchi18n = YamlConfiguration.loadConfiguration(enchi18nFile); enchi18n.options().copyDefaults(false); YamlConfiguration enchi18nYAML = - YamlConfiguration.loadConfiguration( - new InputStreamReader(Objects.requireNonNull(plugin.getResource("enchi18n.yml")))); + YamlConfiguration.loadConfiguration( + new InputStreamReader(Objects.requireNonNull(plugin.getResource("enchi18n.yml")))); enchi18n.setDefaults(enchi18nYAML); Util.parseColours(enchi18n); Enchantment[] enchsi18n = Enchantment.values(); @@ -343,10 +343,10 @@ public class MsgUtil { } catch (IOException e) { e.printStackTrace(); plugin - .getLogger() - .log( - Level.WARNING, - "Could not load/save transaction enchname from enchi18n.yml. Skipping."); + .getLogger() + .log( + Level.WARNING, + "Could not load/save transaction enchname from enchi18n.yml. Skipping."); } plugin.getLogger().info("Complete to load enchname i18n."); } @@ -364,8 +364,8 @@ public class MsgUtil { itemi18n = YamlConfiguration.loadConfiguration(itemi18nFile); itemi18n.options().copyDefaults(false); YamlConfiguration itemi18nYAML = - YamlConfiguration.loadConfiguration( - new InputStreamReader(Objects.requireNonNull(plugin.getResource("itemi18n.yml")))); + YamlConfiguration.loadConfiguration( + new InputStreamReader(Objects.requireNonNull(plugin.getResource("itemi18n.yml")))); itemi18n.setDefaults(itemi18nYAML); Util.parseColours(itemi18n); Material[] itemsi18n = Material.values(); @@ -377,18 +377,18 @@ public class MsgUtil { String itemName = gameLanguage.getItem(material); itemi18n.set("itemi18n." + material.name(), itemName); plugin - .getLogger() - .info("Found new items/blocks [" + itemName + "] , adding it to the config..."); + .getLogger() + .info("Found new items/blocks [" + itemName + "] , adding it to the config..."); } try { itemi18n.save(itemi18nFile); } catch (IOException e) { e.printStackTrace(); plugin - .getLogger() - .log( - Level.WARNING, - "Could not load/save transaction itemname from itemi18n.yml. Skipping."); + .getLogger() + .log( + Level.WARNING, + "Could not load/save transaction itemname from itemi18n.yml. Skipping."); } plugin.getLogger().info("Complete to load Itemname i18n."); } @@ -404,8 +404,8 @@ public class MsgUtil { potioni18n = YamlConfiguration.loadConfiguration(potioni18nFile); potioni18n.options().copyDefaults(false); YamlConfiguration potioni18nYAML = - YamlConfiguration.loadConfiguration( - new InputStreamReader(Objects.requireNonNull(plugin.getResource("potioni18n.yml")))); + YamlConfiguration.loadConfiguration( + new InputStreamReader(Objects.requireNonNull(plugin.getResource("potioni18n.yml")))); potioni18n.setDefaults(potioni18nYAML); Util.parseColours(potioni18n); for (PotionEffectType potion : PotionEffectType.values()) { @@ -422,10 +422,10 @@ public class MsgUtil { } catch (IOException e) { e.printStackTrace(); plugin - .getLogger() - .log( - Level.WARNING, - "Could not load/save transaction potionname from potioni18n.yml. Skipping."); + .getLogger() + .log( + Level.WARNING, + "Could not load/save transaction potionname from potioni18n.yml. Skipping."); } plugin.getLogger().info("Complete to load potionname i18n."); } @@ -447,21 +447,21 @@ public class MsgUtil { } String message = rs.getString("message"); LinkedList msgs = - player_messages.computeIfAbsent(ownerUUID, k -> new LinkedList<>()); + player_messages.computeIfAbsent(ownerUUID, k -> new LinkedList<>()); msgs.add(message); } } catch (SQLException e) { e.printStackTrace(); plugin - .getLogger() - .log(Level.WARNING, "Could not load transaction messages from database. Skipping."); + .getLogger() + .log(Level.WARNING, "Could not load transaction messages from database. Skipping."); } } /** - * @param player The name of the player to message - * @param message The message to send them Sends the given player a message if they're online. - * Else, if they're not online, queues it for them in the database. + * @param player The name of the player to message + * @param message The message to send them Sends the given player a message if they're online. + * Else, if they're not online, queues it for them in the database. * @param isUnlimited The shop is or unlimited */ public static void send(@NotNull UUID player, @NotNull String message, boolean isUnlimited) { @@ -499,7 +499,7 @@ public class MsgUtil { } public static @NotNull String getSubString( - @NotNull String text, @NotNull String left, @NotNull String right) { + @NotNull String text, @NotNull String left, @NotNull String right) { String result; int zLen; if (left.isEmpty()) { @@ -524,11 +524,11 @@ public class MsgUtil { * Send controlPanel infomation to sender * * @param sender Target sender - * @param shop Target shop + * @param shop Target shop */ public static void sendControlPanelInfo(@NotNull CommandSender sender, @NotNull Shop shop) { if ((sender instanceof Player && !sender.isOp()) - && !QuickShop.getPermissionManager().hasPermission(sender, "quickshop.use")) { + && !QuickShop.getPermissionManager().hasPermission(sender, "quickshop.use")) { return; } if (plugin.getConfig().getBoolean("sneak-to-control")) { @@ -546,72 +546,72 @@ public class MsgUtil { chatSheetPrinter.printLine(MsgUtil.getMessage("menu.owner", sender, shop.ownerName())); } else { chatSheetPrinter.printSuggestableCmdLine( - MsgUtil.getMessage( - "controlpanel.setowner", - sender, - shop.ownerName() - + ((plugin.getConfig().getBoolean("shop.show-owner-uuid-in-controlpanel-if-op") - && shop.isUnlimited()) - ? (" (" + shop.getOwner() + ")") - : "")), - MsgUtil.getMessage("controlpanel.setowner-hover", sender), - MsgUtil.getMessage("controlpanel.commands.setowner", sender)); + MsgUtil.getMessage( + "controlpanel.setowner", + sender, + shop.ownerName() + + ((plugin.getConfig().getBoolean("shop.show-owner-uuid-in-controlpanel-if-op") + && shop.isUnlimited()) + ? (" (" + shop.getOwner() + ")") + : "")), + MsgUtil.getMessage("controlpanel.setowner-hover", sender), + MsgUtil.getMessage("controlpanel.commands.setowner", sender)); } // Unlimited if (QuickShop.getPermissionManager().hasPermission(sender, "quickshop.unlimited")) { String text = - MsgUtil.getMessage("controlpanel.unlimited", sender, bool2String(shop.isUnlimited())); + MsgUtil.getMessage("controlpanel.unlimited", sender, bool2String(shop.isUnlimited())); String hoverText = MsgUtil.getMessage("controlpanel.unlimited-hover", sender); String clickCommand = - MsgUtil.getMessage( - "controlpanel.commands.unlimited", - sender, - Objects.requireNonNull(shop.getLocation().getWorld()).getName(), - String.valueOf(shop.getLocation().getBlockX()), - String.valueOf(shop.getLocation().getBlockY()), - String.valueOf(shop.getLocation().getBlockZ())); + MsgUtil.getMessage( + "controlpanel.commands.unlimited", + sender, + Objects.requireNonNull(shop.getLocation().getWorld()).getName(), + String.valueOf(shop.getLocation().getBlockX()), + String.valueOf(shop.getLocation().getBlockY()), + String.valueOf(shop.getLocation().getBlockZ())); chatSheetPrinter.printExecuteableCmdLine(text, hoverText, clickCommand); } // Buying/Selling Mode if (QuickShop.getPermissionManager().hasPermission(sender, "quickshop.create.buy") - && sender.hasPermission("quickshop.create.sell")) { + && sender.hasPermission("quickshop.create.sell")) { if (shop.isSelling()) { String text = MsgUtil.getMessage("controlpanel.mode-selling", sender); String hoverText = MsgUtil.getMessage("controlpanel.mode-selling-hover", sender); String clickCommand = - MsgUtil.getMessage( - "controlpanel.commands.buy", - sender, - Objects.requireNonNull(shop.getLocation().getWorld()).getName(), - String.valueOf(shop.getLocation().getBlockX()), - String.valueOf(shop.getLocation().getBlockY()), - String.valueOf(shop.getLocation().getBlockZ())); + MsgUtil.getMessage( + "controlpanel.commands.buy", + sender, + Objects.requireNonNull(shop.getLocation().getWorld()).getName(), + String.valueOf(shop.getLocation().getBlockX()), + String.valueOf(shop.getLocation().getBlockY()), + String.valueOf(shop.getLocation().getBlockZ())); chatSheetPrinter.printExecuteableCmdLine(text, hoverText, clickCommand); } else if (shop.isBuying()) { String text = MsgUtil.getMessage("controlpanel.mode-buying", sender); String hoverText = MsgUtil.getMessage("controlpanel.mode-buying-hover", sender); String clickCommand = - MsgUtil.getMessage( - "controlpanel.commands.sell", - sender, - Objects.requireNonNull(shop.getLocation().getWorld()).getName(), - String.valueOf(shop.getLocation().getBlockX()), - String.valueOf(shop.getLocation().getBlockY()), - String.valueOf(shop.getLocation().getBlockZ())); + MsgUtil.getMessage( + "controlpanel.commands.sell", + sender, + Objects.requireNonNull(shop.getLocation().getWorld()).getName(), + String.valueOf(shop.getLocation().getBlockX()), + String.valueOf(shop.getLocation().getBlockY()), + String.valueOf(shop.getLocation().getBlockZ())); chatSheetPrinter.printExecuteableCmdLine(text, hoverText, clickCommand); } } // Set Price if (QuickShop.getPermissionManager().hasPermission(sender, "quickshop.other.price") - || shop.getOwner().equals(((OfflinePlayer) sender).getUniqueId())) { + || shop.getOwner().equals(((OfflinePlayer) sender).getUniqueId())) { String text = - MsgUtil.getMessage( - "controlpanel.price", - sender, - (plugin.getConfig().getBoolean("use-decimal-format")) - ? decimalFormat(shop.getPrice()) - : "" + shop.getPrice()); + MsgUtil.getMessage( + "controlpanel.price", + sender, + (plugin.getConfig().getBoolean("use-decimal-format")) + ? decimalFormat(shop.getPrice()) + : "" + shop.getPrice()); String hoverText = MsgUtil.getMessage("controlpanel.price-hover", sender); String clickCommand = MsgUtil.getMessage("controlpanel.commands.price", sender); chatSheetPrinter.printSuggestableCmdLine(text, hoverText, clickCommand); @@ -619,7 +619,7 @@ public class MsgUtil { // Refill if (QuickShop.getPermissionManager().hasPermission(sender, "quickshop.refill")) { String text = - MsgUtil.getMessage("controlpanel.refill", sender, String.valueOf(shop.getPrice())); + MsgUtil.getMessage("controlpanel.refill", sender, String.valueOf(shop.getPrice())); String hoverText = MsgUtil.getMessage("controlpanel.refill-hover", sender); String clickCommand = MsgUtil.getMessage("controlpanel.commands.refill", sender); chatSheetPrinter.printSuggestableCmdLine(text, hoverText, clickCommand); @@ -627,32 +627,32 @@ public class MsgUtil { // Refill if (QuickShop.getPermissionManager().hasPermission(sender, "quickshop.empty")) { String text = - MsgUtil.getMessage("controlpanel.empty", sender, String.valueOf(shop.getPrice())); + MsgUtil.getMessage("controlpanel.empty", sender, String.valueOf(shop.getPrice())); String hoverText = MsgUtil.getMessage("controlpanel.empty-hover", sender); String clickCommand = - MsgUtil.getMessage( - "controlpanel.commands.empty", - sender, - Objects.requireNonNull(shop.getLocation().getWorld()).getName(), - String.valueOf(shop.getLocation().getBlockX()), - String.valueOf(shop.getLocation().getBlockY()), - String.valueOf(shop.getLocation().getBlockZ())); + MsgUtil.getMessage( + "controlpanel.commands.empty", + sender, + Objects.requireNonNull(shop.getLocation().getWorld()).getName(), + String.valueOf(shop.getLocation().getBlockX()), + String.valueOf(shop.getLocation().getBlockY()), + String.valueOf(shop.getLocation().getBlockZ())); chatSheetPrinter.printExecuteableCmdLine(text, hoverText, clickCommand); } // Remove if (QuickShop.getPermissionManager().hasPermission(sender, "quickshop.other.destroy") - || shop.getOwner().equals(((OfflinePlayer) sender).getUniqueId())) { + || shop.getOwner().equals(((OfflinePlayer) sender).getUniqueId())) { String text = - MsgUtil.getMessage("controlpanel.remove", sender, String.valueOf(shop.getPrice())); + MsgUtil.getMessage("controlpanel.remove", sender, String.valueOf(shop.getPrice())); String hoverText = MsgUtil.getMessage("controlpanel.remove-hover", sender); String clickCommand = - MsgUtil.getMessage( - "controlpanel.commands.remove", - sender, - Objects.requireNonNull(shop.getLocation().getWorld()).getName(), - String.valueOf(shop.getLocation().getBlockX()), - String.valueOf(shop.getLocation().getBlockY()), - String.valueOf(shop.getLocation().getBlockZ())); + MsgUtil.getMessage( + "controlpanel.commands.remove", + sender, + Objects.requireNonNull(shop.getLocation().getWorld()).getName(), + String.valueOf(shop.getLocation().getBlockX()), + String.valueOf(shop.getLocation().getBlockY()), + String.valueOf(shop.getLocation().getBlockZ())); chatSheetPrinter.printExecuteableCmdLine(text, hoverText, clickCommand); } @@ -662,13 +662,13 @@ public class MsgUtil { /** * getMessage in messages.yml * - * @param loc location - * @param args args + * @param loc location + * @param args args * @param player The sender will send the message to * @return message */ public static String getMessage( - @NotNull String loc, @Nullable CommandSender player, @NotNull String... args) { + @NotNull String loc, @Nullable CommandSender player, @NotNull String... args) { try { Optional raw = messagei18n.getString(loc); if (!raw.isPresent()) { @@ -727,7 +727,7 @@ public class MsgUtil { if (content == null) { Util.debugLog("Content is null"); Throwable throwable = - new Throwable("Known issue: Global Alert accepted null string, what the fuck"); + new Throwable("Known issue: Global Alert accepted null string, what the fuck"); plugin.getSentryErrorReporter().sendError(throwable, "NullCheck"); return; } @@ -748,7 +748,7 @@ public class MsgUtil { public void run() { for (Player player : Bukkit.getOnlinePlayers()) { if (player.isOp() - || QuickShop.getPermissionManager().hasPermission(player, "quickshop.alert")) { + || QuickShop.getPermissionManager().hasPermission(player, "quickshop.alert")) { player.sendMessage(message); } } @@ -759,8 +759,8 @@ public class MsgUtil { /** * Send a purchaseSuccess message for a player. * - * @param p Target player - * @param shop Target shop + * @param p Target player + * @param shop Target shop * @param amount Trading item amounts. */ public static void sendPurchaseSuccess(@NotNull Player p, @NotNull Shop shop, int amount) { @@ -768,12 +768,12 @@ public class MsgUtil { chatSheetPrinter.printHeader(); chatSheetPrinter.printLine(MsgUtil.getMessage("menu.successful-purchase", p)); chatSheetPrinter.printLine( - MsgUtil.getMessage( - "menu.item-name-and-price", - p, - "" + amount, - Util.getItemStackName(shop.getItem()), - Util.format((amount * shop.getPrice())))); + MsgUtil.getMessage( + "menu.item-name-and-price", + p, + "" + amount, + Util.getItemStackName(shop.getItem()), + Util.format((amount * shop.getPrice())))); printEnchantment(p, shop, chatSheetPrinter); chatSheetPrinter.printFooter(); } @@ -799,8 +799,8 @@ public class MsgUtil { /** * Send a sellSuccess message for a player. * - * @param p Target player - * @param shop Target shop + * @param p Target player + * @param shop Target shop * @param amount Trading item amounts. */ public static void sendSellSuccess(@NotNull Player p, @NotNull Shop shop, int amount) { @@ -808,19 +808,19 @@ public class MsgUtil { chatSheetPrinter.printHeader(); chatSheetPrinter.printLine(MsgUtil.getMessage("menu.successfully-sold", p)); chatSheetPrinter.printLine( - MsgUtil.getMessage( - "menu.item-name-and-price", - p, - "" + amount, - Util.getItemStackName(shop.getItem()), - Util.format((amount * shop.getPrice())))); + MsgUtil.getMessage( + "menu.item-name-and-price", + p, + "" + amount, + Util.getItemStackName(shop.getItem()), + Util.format((amount * shop.getPrice())))); if (plugin.getConfig().getBoolean("show-tax")) { double tax = plugin.getConfig().getDouble("tax"); double total = amount * shop.getPrice(); if (tax != 0) { if (!p.getUniqueId().equals(shop.getOwner())) { chatSheetPrinter.printLine( - MsgUtil.getMessage("menu.sell-tax", p, Util.format((tax * total)))); + MsgUtil.getMessage("menu.sell-tax", p, Util.format((tax * total)))); } else { chatSheetPrinter.printLine(MsgUtil.getMessage("menu.sell-tax-self", p)); } @@ -831,11 +831,11 @@ public class MsgUtil { } private static void printEnchantment(@NotNull Player p, @NotNull Shop shop, ChatSheetPrinter chatSheetPrinter) { - if (shop.getItem().hasItemMeta()&&shop.getItem().getItemMeta().hasItemFlag(ItemFlag.HIDE_ENCHANTS) && plugin.getConfig().getBoolean("respect-item-flag")) { + if (shop.getItem().hasItemMeta() && shop.getItem().getItemMeta().hasItemFlag(ItemFlag.HIDE_ENCHANTS) && plugin.getConfig().getBoolean("respect-item-flag")) { return; } Map enchs = new HashMap<>(); - if (shop.getItem().hasItemMeta()&& shop.getItem().getItemMeta().hasEnchants()) { + if (shop.getItem().hasItemMeta() && shop.getItem().getItemMeta().hasEnchants()) { enchs = shop.getItem().getItemMeta().getEnchants(); } if (!enchs.isEmpty()) { @@ -860,7 +860,7 @@ public class MsgUtil { /** * Send a shop infomation to a player. * - * @param p Target player + * @param p Target player * @param shop The shop */ public static void sendShopInfo(@NotNull Player p, @NotNull Shop shop) { @@ -872,46 +872,46 @@ public class MsgUtil { chatSheetPrinter.printLine(MsgUtil.getMessage("menu.owner", p, shop.ownerName())); // Enabled sendItemholochat( - shop, - items, - p, - ChatColor.DARK_PURPLE - + MsgUtil.getMessage("tableformat.left_begin", p) - + " " - + MsgUtil.getMessage("menu.item", p, Util.getItemStackName(items))); + shop, + items, + p, + ChatColor.DARK_PURPLE + + MsgUtil.getMessage("tableformat.left_begin", p) + + " " + + MsgUtil.getMessage("menu.item", p, Util.getItemStackName(items))); if (Util.isTool(items.getType())) { chatSheetPrinter.printLine( - MsgUtil.getMessage("menu.damage-percent-remaining", p, Util.getToolPercentage(items))); + MsgUtil.getMessage("menu.damage-percent-remaining", p, Util.getToolPercentage(items))); } if (shop.isSelling()) { if (shop.getRemainingStock() == -1) { chatSheetPrinter.printLine( - MsgUtil.getMessage("menu.stock", p, "" + MsgUtil.getMessage("signs.unlimited", p))); + MsgUtil.getMessage("menu.stock", p, "" + MsgUtil.getMessage("signs.unlimited", p))); } else { chatSheetPrinter.printLine( - MsgUtil.getMessage("menu.stock", p, "" + shop.getRemainingStock())); + MsgUtil.getMessage("menu.stock", p, "" + shop.getRemainingStock())); } } else { if (shop.getRemainingSpace() == -1) { chatSheetPrinter.printLine( - MsgUtil.getMessage("menu.space", p, "" + MsgUtil.getMessage("signs.unlimited", p))); + MsgUtil.getMessage("menu.space", p, "" + MsgUtil.getMessage("signs.unlimited", p))); } else { chatSheetPrinter.printLine( - MsgUtil.getMessage("menu.space", p, "" + shop.getRemainingSpace())); + MsgUtil.getMessage("menu.space", p, "" + shop.getRemainingSpace())); } } chatSheetPrinter.printLine( - MsgUtil.getMessage( - "menu.price-per", - p, - Util.getItemStackName(shop.getItem()), - Util.format(shop.getPrice()))); + MsgUtil.getMessage( + "menu.price-per", + p, + Util.getItemStackName(shop.getItem()), + Util.format(shop.getPrice()))); if (shop.isBuying()) { chatSheetPrinter.printLine(MsgUtil.getMessage("menu.this-shop-is-buying", p)); } else { chatSheetPrinter.printLine(MsgUtil.getMessage("menu.this-shop-is-selling", p)); } - printEnchantment(p,shop,chatSheetPrinter); + printEnchantment(p, shop, chatSheetPrinter); if (items.getItemMeta() instanceof PotionMeta) { PotionMeta potionMeta = (PotionMeta) items.getItemMeta(); PotionEffectType potionEffectType = potionMeta.getBasePotionData().getType().getEffectType(); @@ -920,11 +920,11 @@ public class MsgUtil { chatSheetPrinter.printLine(ChatColor.YELLOW + MsgUtil.getPotioni18n(potionEffectType)); } potionMeta - .getCustomEffects() - .forEach( - (potionEffect -> - chatSheetPrinter.printLine( - ChatColor.YELLOW + MsgUtil.getPotioni18n(potionEffect.getType())))); + .getCustomEffects() + .forEach( + (potionEffect -> + chatSheetPrinter.printLine( + ChatColor.YELLOW + MsgUtil.getPotioni18n(potionEffect.getType())))); } chatSheetPrinter.printFooter(); } @@ -932,35 +932,35 @@ public class MsgUtil { /** * Send the ItemPreview chat msg by NMS. * - * @param shop Target shop - * @param itemStack Target ItemStack - * @param player Target player + * @param shop Target shop + * @param itemStack Target ItemStack + * @param player Target player * @param normalText The text you will see */ public static void sendItemholochat( - @NotNull Shop shop, - @NotNull ItemStack itemStack, - @NotNull Player player, - @NotNull String normalText) { + @NotNull Shop shop, + @NotNull ItemStack itemStack, + @NotNull Player player, + @NotNull String normalText) { try { String json = ItemNMS.saveJsonfromNMS(itemStack); if (json == null) { return; } TextComponent normalmessage = - new TextComponent(normalText + " " + MsgUtil.getMessage("menu.preview", player)); + new TextComponent(normalText + " " + MsgUtil.getMessage("menu.preview", player)); ComponentBuilder cBuilder = new ComponentBuilder(json); if (QuickShop.getPermissionManager().hasPermission(player, "quickshop.preview")) { normalmessage.setClickEvent( - new ClickEvent( - ClickEvent.Action.RUN_COMMAND, - MsgUtil.getMessage( - "menu.commands.preview", - player, - Objects.requireNonNull(shop.getLocation().getWorld()).getName(), - String.valueOf(shop.getLocation().getBlockX()), - String.valueOf(shop.getLocation().getBlockY()), - String.valueOf(shop.getLocation().getBlockZ())))); + new ClickEvent( + ClickEvent.Action.RUN_COMMAND, + MsgUtil.getMessage( + "menu.commands.preview", + player, + Objects.requireNonNull(shop.getLocation().getWorld()).getName(), + String.valueOf(shop.getLocation().getBlockX()), + String.valueOf(shop.getLocation().getBlockY()), + String.valueOf(shop.getLocation().getBlockZ())))); } normalmessage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_ITEM, cBuilder.create())); player.spigot().sendMessage(normalmessage); @@ -1020,30 +1020,30 @@ public class MsgUtil { setAndUpdate("controlpanel.infomation", "&aShop Control Panel:"); setAndUpdate("controlpanel.setowner", "&aOwner: &b{0} &e[&d&lChange&e]"); setAndUpdate( - "controlpanel.setowner-hover", - "&eLooking you want changing shop and click to switch owner."); + "controlpanel.setowner-hover", + "&eLooking you want changing shop and click to switch owner."); setAndUpdate("controlpanel.unlimited", "&aUnlimited: {0} &e[&d&lSwitch&e]"); messagei18n.set( - "controlpanel.unlimited-hover", - "&eLooking you want changing shop and click to switch enabled or disabled."); + "controlpanel.unlimited-hover", + "&eLooking you want changing shop and click to switch enabled or disabled."); setAndUpdate("controlpanel.mode-selling", "&aShop mode: &bSelling &e[&d&lSwitch&e]"); messagei18n.set( - "controlpanel.mode-selling-hover", - "&eLooking you want changing shop and click to switch enabled or disabled."); + "controlpanel.mode-selling-hover", + "&eLooking you want changing shop and click to switch enabled or disabled."); setAndUpdate("controlpanel.mode-buying", "&aShop mode: &bBuying &e[&d&lSwitch&e]"); messagei18n.set( - "controlpanel.mode-buying-hover", - "&eLooking you want changing shop and click to switch enabled or disabled."); + "controlpanel.mode-buying-hover", + "&eLooking you want changing shop and click to switch enabled or disabled."); setAndUpdate("controlpanel.price", "&aPrice: &b{0} &e[&d&lSet&e]"); setAndUpdate( - "controlpanel.price-hover", - "&eLooking you want changing shop and click to set new price."); + "controlpanel.price-hover", + "&eLooking you want changing shop and click to set new price."); setAndUpdate("controlpanel.refill", "&aRefill: Refill the shop items &e[&d&lOK&e]"); setAndUpdate( - "controlpanel.refill-hover", "&eLooking you want changing shop and click to refill."); + "controlpanel.refill-hover", "&eLooking you want changing shop and click to refill."); setAndUpdate("controlpanel.empty", "&aEmpty: Remove shop all items &e[&d&lOK&e]"); setAndUpdate( - "controlpanel.empty-hover", "&eLooking you want changing shop and click to clear."); + "controlpanel.empty-hover", "&eLooking you want changing shop and click to clear."); setAndUpdate("controlpanel.remove", "&c&l[Remove Shop]"); setAndUpdate("controlpanel.remove-hover", "&eClick to remove this shop."); setAndUpdate("language-version", 2); @@ -1053,8 +1053,8 @@ public class MsgUtil { setAndUpdate("command.no-target-given", "&cUsage: /qs export mysql|sqlite"); setAndUpdate("command.description.debug", "&ePrint debug infomation"); messagei18n.set( - "no-permission-remove-shop", - "&cYou do not have permission to use that command. Try break the shop instead?"); + "no-permission-remove-shop", + "&cYou do not have permission to use that command. Try break the shop instead?"); setAndUpdate("language-version", 3); selectedVersion = 3; } @@ -1092,30 +1092,30 @@ public class MsgUtil { setAndUpdate("command.description.debug", "&eSwitch to developer mode"); setAndUpdate("break-shop-use-supertool", "&eYou break the shop by use SuperTool."); messagei18n.set( - "no-creative-break", - "&cYou cannot break other players shops in creative mode. Use survival instead or use SuperTool ({0})."); + "no-creative-break", + "&cYou cannot break other players shops in creative mode. Use survival instead or use SuperTool ({0})."); setAndUpdate( - "command.now-debuging", - "&aSuccessfully switch to developer mode, Reloading QuickShop..."); + "command.now-debuging", + "&aSuccessfully switch to developer mode, Reloading QuickShop..."); setAndUpdate( - "command.now-nolonger-debuging", - "&aSuccessfully switch to production mode, Reloading QuickShop..."); + "command.now-nolonger-debuging", + "&aSuccessfully switch to production mode, Reloading QuickShop..."); setAndUpdate("language-version", 7); selectedVersion = 7; } if (selectedVersion == 7) { setAndUpdate( - "failed-to-put-sign", "&cNo enough space around the shop to place infomation sign."); + "failed-to-put-sign", "&cNo enough space around the shop to place infomation sign."); setAndUpdate("language-version", 8); selectedVersion = 8; } if (selectedVersion == 8) { messagei18n.set( - "failed-to-paste", - "&cFailed upload data to Pastebin, Check the internet and try again. (See console for details)"); + "failed-to-paste", + "&cFailed upload data to Pastebin, Check the internet and try again. (See console for details)"); messagei18n.set( - "warn-to-paste", - "&eCollecting data and upload to Pastebin, this may need a while. &c&lWarning&c, The data is keep public one week, it may leak your server configuration, make sure you only send it to your <rusted staff/developer."); + "warn-to-paste", + "&eCollecting data and upload to Pastebin, this may need a while. &c&lWarning&c, The data is keep public one week, it may leak your server configuration, make sure you only send it to your <rusted staff/developer."); setAndUpdate("command.description.paste", "&eAuto upload server data to Pastebin"); setAndUpdate("language-version", 9); selectedVersion = 9; @@ -1130,7 +1130,7 @@ public class MsgUtil { setAndUpdate("controlpanel.commands.empty", "/qs silentempty {0} {1} {2} {3}"); setAndUpdate("controlpanel.commands.remove", "/qs silentremove {0} {1} {2} {3}"); setAndUpdate( - "tableformat.full_line", "+---------------------------------------------------+"); + "tableformat.full_line", "+---------------------------------------------------+"); setAndUpdate("tableformat.left_half_line", "+--------------------"); setAndUpdate("tableformat.right_half_line", "--------------------+"); setAndUpdate("tableformat.left_begin", "| "); @@ -1141,20 +1141,20 @@ public class MsgUtil { } if (selectedVersion == 10) { setAndUpdate( - "price-too-high", "&cShop price too high! You can't create price higher than {0} shop."); + "price-too-high", "&cShop price too high! You can't create price higher than {0} shop."); setAndUpdate("language-version", 11); selectedVersion = 11; } if (selectedVersion == 11) { setAndUpdate( - "unknown-player", "&cTarget player not exist, please check username your typed."); + "unknown-player", "&cTarget player not exist, please check username your typed."); setAndUpdate("shop-staff-cleared", "&aSuccessfully remove all staff for your shop."); setAndUpdate("shop-staff-added", "&aSuccessfully add {0} to your shop staffs."); setAndUpdate("shop-staff-deleted", "&aSuccessfully remove {0} to your shop staffs."); setAndUpdate("command.wrong-args", "&cParameters not matched, use /qs help to check help"); setAndUpdate("command.description.staff", "&eManage your shop staffs."); setAndUpdate( - "unknown-player", "&cTarget player not exist, please check username your typed."); + "unknown-player", "&cTarget player not exist, please check username your typed."); setAndUpdate("language-version", 12); selectedVersion = 12; } @@ -1166,7 +1166,7 @@ public class MsgUtil { setAndUpdate("command.wrong-args", "&cParameters not matched, use /qs help to check help"); setAndUpdate("command.description.staff", "&eManage your shop staffs."); setAndUpdate( - "unknown-player", "&cTarget player not exist, please check username your typed."); + "unknown-player", "&cTarget player not exist, please check username your typed."); setAndUpdate("language-version", 13); selectedVersion = 13; } @@ -1202,8 +1202,8 @@ public class MsgUtil { } if (selectedVersion == 15) { setAndUpdate( - "purchase-failed", - "&cPurchase failed: Internal Error, please contact the server administrator.."); + "purchase-failed", + "&cPurchase failed: Internal Error, please contact the server administrator.."); setAndUpdate("language-version", 16); selectedVersion = 16; } @@ -1211,8 +1211,8 @@ public class MsgUtil { setAndUpdate("command.description.owner", "&eChanges who owns a shop"); setAndUpdate("command.description.remove", "&eRemove your looking the shop"); setAndUpdate( - "command.description.amount", - "&eExecute for your actions with amount(For chat plugin issue)"); + "command.description.amount", + "&eExecute for your actions with amount(For chat plugin issue)"); setAndUpdate("command.description.about", "&eShow QuickShop abouts"); setAndUpdate("command.description.help", "&eShow QuickShop helps"); setAndUpdate("no-pending-action", "&cYou do not have any pending action"); @@ -1226,25 +1226,25 @@ public class MsgUtil { } if (selectedVersion == 18) { setAndUpdate( - "command.description.supercreate", "&eCreate a shop bypass all protection checks"); + "command.description.supercreate", "&eCreate a shop bypass all protection checks"); setAndUpdate("language-version", 19); selectedVersion = 19; } if (selectedVersion == 19) { setAndUpdate("permission-denied-3rd-party", "&cPermission denied: 3rd party plugin [{0}]."); setAndUpdate( - "updatenotify.remote-disable-warning", - "&cThis version of QuickShop is marked disabled by remote server, that mean this version may have serious problem, get details from our SpigotMC page: {0}. This warning will appear and spam your console until you use other not disabled version to replace this one, doesn't effect your server running."); + "updatenotify.remote-disable-warning", + "&cThis version of QuickShop is marked disabled by remote server, that mean this version may have serious problem, get details from our SpigotMC page: {0}. This warning will appear and spam your console until you use other not disabled version to replace this one, doesn't effect your server running."); setAndUpdate("language-version", 20); selectedVersion = 20; } if (selectedVersion == 20) { setAndUpdate( - "how-many-buy", - "&aEnter how many you wish to &bBUY&a in chat. Enter &ball&a to buy them all."); + "how-many-buy", + "&aEnter how many you wish to &bBUY&a in chat. Enter &ball&a to buy them all."); setAndUpdate( - "how-many-sell", - "&aEnter how many you wish to &dSELL&a in chat. You have &e{0}&a available. Enter &ball&a to sell them all."); + "how-many-sell", + "&aEnter how many you wish to &dSELL&a in chat. You have &e{0}&a available. Enter &ball&a to sell them all."); setAndUpdate("updatenotify.label.unstable", "[Unstable]"); setAndUpdate("updatenotify.label.stable", "[Stable]"); setAndUpdate("updatenotify.label.lts", "[LTS]"); @@ -1257,8 +1257,8 @@ public class MsgUtil { } if (selectedVersion == 21) { setAndUpdate( - "shop-removed-cause-ongoing-fee", - "&cYou shop at {0} was removed cause you had no enough money to keep it!"); + "shop-removed-cause-ongoing-fee", + "&cYou shop at {0} was removed cause you had no enough money to keep it!"); setAndUpdate("language-version", 22); selectedVersion = 22; } @@ -1276,8 +1276,8 @@ public class MsgUtil { } if (selectedVersion == 24) { setAndUpdate( - "digits-reach-the-limit", - "&cYou have reach the limit of the digits after the dot in price."); + "digits-reach-the-limit", + "&cYou have reach the limit of the digits after the dot in price."); setAndUpdate("language-version", 25); selectedVersion = 25; } @@ -1330,6 +1330,13 @@ public class MsgUtil { setAndUpdate("language-version", 30); selectedVersion = 30; } + if (selectedVersion == 30) { + setAndUpdate("no-creative-break", "&cYou cannot break other players shops in the creative mode, switch to survival mode or try to use supertool {0} instead."); + setAndUpdate("trading-in-creative-mode-is-disabled", "&cYou cannot trade with shop in the creative mode."); + setAndUpdate("supertool-is-disabled", "&cSupertool is disabled, cannot break any shop."); + setAndUpdate("language-version", 31); + selectedVersion = 31; + } messagei18n.save(); messagei18n.loadFromString(Util.parseColours(messagei18n.saveToString())); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index c6fb1ecfc..4ca8bac6e 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1,7 +1,7 @@ #This is example config, don't direct modify this file, all changes will revert when you reload the plugin. #Do not touch if you not clear know about this -config-version: 91 +config-version: 93 #Select the language you want to use, (e.g de), use only supported language codes from the list below. #If you use a not exist/not support language, plugin will move to use en_US to keep everything working. @@ -154,6 +154,13 @@ shop: #Should we refund the player when their shops are deleted/removed/broken? refund: false + #Should we disable trading for creative mode? + disable-creative-mode-trading: false + #Should we disable super tool?(It's a tool which allow you break shop in creative mode by gold axe) + disable-super-tool: false + #Should we allow the owner of shop break the sign (for sign replacement or reduce lag)? + allow-owner-break-shop-sign: true + #Is there a fee for changing prices on a shop (Help deter endless undercutting) price-change-requires-fee: true #If price changes require a fee, how much is the fee diff --git a/src/main/resources/lang-original/messages.json b/src/main/resources/lang-original/messages.json index 3aca876e1..f9886aa76 100644 --- a/src/main/resources/lang-original/messages.json +++ b/src/main/resources/lang-original/messages.json @@ -3,12 +3,14 @@ "translation-version": "Support Version: Reremake", "translation-contributors": "Contributors: Timtower, Netherfoam, KaiNoMood and Mgazul", "translation-country": "Language Zone: English (en_US)", - "language-version": "30", + "language-version": "31", "not-looking-at-shop": "&cNo QuickShop was found, you must be looking at one.", "no-anythings-in-your-hand": "&cThere is nothing in your hand.", "no-permission": "&cYou do not have permission to do that.", "3rd-plugin-build-check-failed": "Some 3rd party plugin denied the permission checks, did you have permission built in there?", - "no-creative-break": "&cYou cannot break other players shops in creative mode. Use survival instead.", + "no-creative-break": "&cYou cannot break other players shops in the creative mode, switch to survival mode or try to use supertool {0} instead.", + "trading-in-creative-mode-is-disabled": "&cYou cannot trade with shop in the creative mode.", + "supertool-is-disabled": "&cSupertool is disabled, cannot break any shop.", "no-double-chests": "&cYou cannot create the DoubleChest shop.", "not-managed-shop": "&cYou are not the owner or moderator of the shop", "shop-already-owned": "&cThat is already a shop.",