Optimize performance for IM event in ShopProtectionListener

Former-commit-id: 53be21a0bd63dac9a442444850c46ed681e10f87
This commit is contained in:
Ghost_chu committed 2020-01-21 20:28:49 +08:00
1 parent 35429b74f9
commit b58f0bf3de
1 file changed
+10
@@ -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<Location,Boolean> 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")) {