From b58f0bf3dec15b7d997d5028fe91880ec920018c Mon Sep 17 00:00:00 2001 From: Ghost_chu <2908803755@qq.com> Date: Tue, 21 Jan 2020 20:28:49 +0800 Subject: [PATCH] Optimize performance for IM event in ShopProtectionListener Former-commit-id: 53be21a0bd63dac9a442444850c46ed681e10f87 --- .../quickshop/Listeners/ShopProtectionListener.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/org/maxgamer/quickshop/Listeners/ShopProtectionListener.java b/src/main/java/org/maxgamer/quickshop/Listeners/ShopProtectionListener.java index 98ed1078d..eca22bf19 100644 --- a/src/main/java/org/maxgamer/quickshop/Listeners/ShopProtectionListener.java +++ b/src/main/java/org/maxgamer/quickshop/Listeners/ShopProtectionListener.java @@ -19,7 +19,9 @@ package org.maxgamer.quickshop.Listeners; +import java.util.AbstractMap; import java.util.List; +import java.util.Map; import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; @@ -42,6 +44,7 @@ import org.jetbrains.annotations.NotNull; import org.maxgamer.quickshop.QuickShop; import org.maxgamer.quickshop.Shop.Shop; import org.maxgamer.quickshop.Util.MsgUtil; +import org.maxgamer.quickshop.Util.Util; @SuppressWarnings("DuplicatedCode") public class ShopProtectionListener implements Listener { @@ -154,6 +157,7 @@ public class ShopProtectionListener implements Listener { } // Protect Minecart steal shop + Map.Entry lastInventoryMoveItemCheck = new AbstractMap.SimpleEntry<>(null, null); @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) public void onInventoryMove(InventoryMoveItemEvent event) { if (ListenerHelper.isDisabled(event.getClass())) { @@ -166,6 +170,10 @@ public class ShopProtectionListener implements Listener { return; } + if(!Util.isShoppables(loc.getBlock().getType())){ + return; + } + final Shop shop = plugin.getShopManager().getShopIncludeAttached(loc); if (shop == null) { @@ -186,6 +194,8 @@ public class ShopProtectionListener implements Listener { ((Entity) holder).remove(); } else if (holder instanceof Block) { location.getBlock().breakNaturally(); + }else{ + Util.debugLog("Unknown location = "+loc); } if (plugin.getConfig().getBoolean("send-shop-protection-alert")) {