From 2b93acb406528af0774817938db84035c0c68bac Mon Sep 17 00:00:00 2001 From: Sotr Date: Mon, 29 Oct 2018 01:07:51 +0800 Subject: [PATCH 1/3] Improvements on enum collections Former-commit-id: 638cfb5083176b2d2b6870fe42b209b5ef28880c --- src/main/java/org/maxgamer/quickshop/Util/Util.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/maxgamer/quickshop/Util/Util.java b/src/main/java/org/maxgamer/quickshop/Util/Util.java index 091d3d76c..688587dc2 100644 --- a/src/main/java/org/maxgamer/quickshop/Util/Util.java +++ b/src/main/java/org/maxgamer/quickshop/Util/Util.java @@ -4,6 +4,8 @@ import java.lang.reflect.Method; import java.text.DecimalFormat; import java.util.AbstractMap.SimpleEntry; import java.util.ArrayList; +import java.util.EnumMap; +import java.util.EnumSet; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -47,9 +49,9 @@ import net.md_5.bungee.api.chat.TextComponent; */ @SuppressWarnings("deprecation") public class Util { - private static HashSet blacklist = new HashSet(); - private static HashSet shoppables = new HashSet(); - private static Map> restrictedPrices = new HashMap>(); + private static final EnumSet blacklist = EnumSet.noneOf(Material.class); + private static final EnumSet shoppables = EnumSet.noneOf(Material.class); + private static final EnumMap> restrictedPrices = new EnumMap>(Material.class); private static QuickShop plugin; private static Method storageContents; From e0c54dfdfeee96d88fc8b84c0956980c36301737 Mon Sep 17 00:00:00 2001 From: Sotr Date: Mon, 29 Oct 2018 01:19:07 +0800 Subject: [PATCH 2/3] Ignore cancellation to avoid potential issues Former-commit-id: 1567cdb95276504f64420bcccc71183fc8fd9b01 --- .../org/maxgamer/quickshop/Listeners/ChatListener.java | 2 +- .../quickshop/Listeners/DisplayProtectionListener.java | 8 ++++---- .../org/maxgamer/quickshop/Listeners/LockListener.java | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/maxgamer/quickshop/Listeners/ChatListener.java b/src/main/java/org/maxgamer/quickshop/Listeners/ChatListener.java index eb745169b..afa16c333 100644 --- a/src/main/java/org/maxgamer/quickshop/Listeners/ChatListener.java +++ b/src/main/java/org/maxgamer/quickshop/Listeners/ChatListener.java @@ -18,7 +18,7 @@ public class ChatListener implements Listener { this.plugin = plugin; } - @EventHandler(priority = EventPriority.LOWEST) + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onChat(final AsyncPlayerChatEvent e) { if (!plugin.getShopManager().getActions().containsKey(e.getPlayer().getUniqueId())) { plugin.log(plugin.getShopManager().getActions().toString()); diff --git a/src/main/java/org/maxgamer/quickshop/Listeners/DisplayProtectionListener.java b/src/main/java/org/maxgamer/quickshop/Listeners/DisplayProtectionListener.java index 249c5c8c3..978d3d854 100644 --- a/src/main/java/org/maxgamer/quickshop/Listeners/DisplayProtectionListener.java +++ b/src/main/java/org/maxgamer/quickshop/Listeners/DisplayProtectionListener.java @@ -21,7 +21,7 @@ public class DisplayProtectionListener implements Listener { this.plugin = plugin; } - @EventHandler + @EventHandler(ignoreCancelled = true) public void onInventoryOpen(InventoryOpenEvent event) { for (int i = 0; i Date: Mon, 29 Oct 2018 01:28:22 +0800 Subject: [PATCH 3/3] Further ignore cancellation Former-commit-id: 08fb5926b229ac71115176a41a057a3f155d83d9 --- .../java/org/maxgamer/quickshop/Listeners/ChunkListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/maxgamer/quickshop/Listeners/ChunkListener.java b/src/main/java/org/maxgamer/quickshop/Listeners/ChunkListener.java index d41609f15..c9f77af0b 100644 --- a/src/main/java/org/maxgamer/quickshop/Listeners/ChunkListener.java +++ b/src/main/java/org/maxgamer/quickshop/Listeners/ChunkListener.java @@ -32,7 +32,7 @@ public class ChunkListener implements Listener { } } - @EventHandler(priority = EventPriority.HIGHEST) + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onChunkUnload(ChunkUnloadEvent e) { Chunk c = e.getChunk(); HashMap inChunk = plugin.getShopManager().getShops(c);