From 5369cf3c95e2dd21c013d22653a2d8648cc58cea Mon Sep 17 00:00:00 2001 From: Ghost_chu <2908803755@qq.com> Date: Fri, 7 Jun 2019 22:42:29 +0800 Subject: [PATCH] Optimize codes Former-commit-id: 725914a67f80177b7554906f9765e4498649d0e3 [formerly b06db6509ee159b6edaaba129d00697bbc64f14f] Former-commit-id: d3d12abc0d7c892f4bdbf4611cfe17e9ff0d97c6 --- .../org/maxgamer/quickshop/Listeners/BlockListener.java | 2 +- .../java/org/maxgamer/quickshop/Shop/ContainerShop.java | 2 +- .../java/org/maxgamer/quickshop/Shop/ShopManager.java | 4 ++-- src/main/java/org/maxgamer/quickshop/Util/Util.java | 9 +++++---- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/maxgamer/quickshop/Listeners/BlockListener.java b/src/main/java/org/maxgamer/quickshop/Listeners/BlockListener.java index 6f475b33e..b62494186 100644 --- a/src/main/java/org/maxgamer/quickshop/Listeners/BlockListener.java +++ b/src/main/java/org/maxgamer/quickshop/Listeners/BlockListener.java @@ -31,7 +31,7 @@ public class BlockListener implements Listener { @EventHandler(ignoreCancelled = true) public void onPlace(BlockPlaceEvent e) { BlockState bs = e.getBlock().getState(); - if (bs instanceof DoubleChest == false) + if (!(bs instanceof DoubleChest)) return; Block b = e.getBlock(); Player p = e.getPlayer(); diff --git a/src/main/java/org/maxgamer/quickshop/Shop/ContainerShop.java b/src/main/java/org/maxgamer/quickshop/Shop/ContainerShop.java index 0f845fee6..4525ba61b 100644 --- a/src/main/java/org/maxgamer/quickshop/Shop/ContainerShop.java +++ b/src/main/java/org/maxgamer/quickshop/Shop/ContainerShop.java @@ -518,7 +518,7 @@ public class ContainerShop implements Shop { * Updates signs attached to the shop */ public void setSignText() { - if (Util.isLoaded(this.getLocation()) == false) + if (!Util.isLoaded(this.getLocation())) return; String[] lines = new String[4]; lines[0] = MsgUtil.getMessage("signs.header", this.ownerName()); diff --git a/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java b/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java index a9a5af267..b595a2ac2 100644 --- a/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java +++ b/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java @@ -361,7 +361,7 @@ public class ShopManager { // Get the shop they interacted with Shop shop = plugin.getShopManager().getShop(info.getLocation()); // It's not valid anymore - if (shop == null || Util.canBeShop(info.getLocation().getBlock()) == false) { + if (shop == null || !Util.canBeShop(info.getLocation().getBlock())) { p.sendMessage(MsgUtil.getMessage("chest-was-removed")); return; } @@ -583,7 +583,7 @@ public class ShopManager { p.sendMessage(MsgUtil.getMessage("no-double-chests")); return; } - if (Util.canBeShop(info.getLocation().getBlock()) == false) { + if (!Util.canBeShop(info.getLocation().getBlock())) { p.sendMessage(MsgUtil.getMessage("chest-was-removed")); return; } diff --git a/src/main/java/org/maxgamer/quickshop/Util/Util.java b/src/main/java/org/maxgamer/quickshop/Util/Util.java index 9587a2147..59be8caeb 100644 --- a/src/main/java/org/maxgamer/quickshop/Util/Util.java +++ b/src/main/java/org/maxgamer/quickshop/Util/Util.java @@ -853,12 +853,13 @@ public class Util { pEffects.add(MsgUtil.getPotioni18n(potionEffect.getType()) + " " + formatEnchLevel(potionEffect.getAmplifier())); } } - if (pEffects != null && pEffects.isEmpty() == false) { - String result = new String(); + if (!pEffects.isEmpty()) { + StringBuilder result = new StringBuilder(); for (String effectString : pEffects) { - result += effectString + "\n"; + result.append(effectString); + result.append("\n"); } - return result; + return result.toString(); } else { return null; }