mirror of
https://github.com/EarthMC/QuickShop-Reremake.git
synced 2026-11-24 17:39:52 -05:00
Optimize performance for IM event in ShopProtectionListener
Former-commit-id: 53be21a0bd63dac9a442444850c46ed681e10f87
This commit is contained in:
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")) {
|
||||
|
||||
Reference in new issue
Block a user