diff --git a/spigot/src/main/java/de/sean/blockprot/bukkit/config/DefaultConfig.java b/spigot/src/main/java/de/sean/blockprot/bukkit/config/DefaultConfig.java index 481b90fc..946998f3 100644 --- a/spigot/src/main/java/de/sean/blockprot/bukkit/config/DefaultConfig.java +++ b/spigot/src/main/java/de/sean/blockprot/bukkit/config/DefaultConfig.java @@ -88,6 +88,8 @@ public final class DefaultConfig extends BlockProtConfig { private final List excludedWorlds; + private final boolean simpleHopperProtection; + /** * Create a new default configuration from given {@code config}. * @@ -98,6 +100,7 @@ public DefaultConfig(@NotNull final FileConfiguration config) { super(config); this.excludedWorlds = config.getStringList("excluded_worlds"); + this.simpleHopperProtection = config.getBoolean("simple_hopper_protection"); this.removeBlockDefaults(); this.loadBlocksFromConfig(); } @@ -404,4 +407,8 @@ public boolean isLockableShulkerBox(Material type) { public boolean isLockableInventory(InventoryType type) { return lockableInventories.contains(type); } + + public boolean isSimpleHopperProtection() { + return simpleHopperProtection; + } } diff --git a/spigot/src/main/java/de/sean/blockprot/bukkit/listeners/HopperEventListener.java b/spigot/src/main/java/de/sean/blockprot/bukkit/listeners/HopperEventListener.java index b10c026d..1bee2798 100644 --- a/spigot/src/main/java/de/sean/blockprot/bukkit/listeners/HopperEventListener.java +++ b/spigot/src/main/java/de/sean/blockprot/bukkit/listeners/HopperEventListener.java @@ -42,6 +42,11 @@ public void onItemMove(InventoryMoveItemEvent event) { if (source != null && BlockProt.getDefaultConfig().isLockable(source.getType())) { BlockNBTHandler sourceHandler = new BlockNBTHandler(source); if (sourceHandler.isProtected()) { + // Check if simple hopper protection is enabled, if so we can skip the rest + if (BlockProt.getDefaultConfig().isSimpleHopperProtection()) { + event.setCancelled(true); + return; + } // The source chest is owned by someone. Check if the hopper block is also owned by // the same player and if so, allow this event to happen, regardless of the hopper // protection. diff --git a/spigot/src/main/resources/config.yml b/spigot/src/main/resources/config.yml index 652cbf48..5a0866ab 100644 --- a/spigot/src/main/resources/config.yml +++ b/spigot/src/main/resources/config.yml @@ -28,6 +28,13 @@ notify_op_of_updates: false # placed block, if the player has lock on place enabled. redstone_disallowed_by_default: false +# Toggle simple hopper protection, meaning any protected chest +# can not be interacted with by any hopper. Should significantly +# improve performance in some cases. +# WARNING: Will fully disable hoppers moving items from ANY +# protected container +simple_hopper_protection: false + # A list of world names the plugin should not be usable in. # The case of each name is ignored. # Useful for a mining-only world where a block should not be