diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterLock.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterLock.java index aff9635a..0e9b567e 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterLock.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterLock.java @@ -111,6 +111,7 @@ public void onWaterMove(BlockFromToEvent e) { private boolean handleMoveItemEvent(Inventory inventory, ItemStack is, boolean isSource) { Location location; + Location locationOtherSide = null; InventoryHolder holder; if(inventory != null){ holder = inventory.getHolder(); @@ -122,18 +123,37 @@ private boolean handleMoveItemEvent(Inventory inventory, ItemStack is, boolean i try { if (holder instanceof BlockState) { location = ((BlockState)holder).getLocation(); - } else if (holder instanceof DoubleChest) { - location = ((DoubleChest)holder).getLocation(); + } else if (holder instanceof DoubleChest doubleChest) { + location = Objects.requireNonNull(doubleChest.getRightSide()).getInventory().getLocation().getBlock().getLocation(); + locationOtherSide = Objects.requireNonNull(doubleChest.getLeftSide()).getInventory().getLocation().getBlock().getLocation(); } else { return false; } } catch (Exception e) { return false; - } + } ProtectionEntry protection = RelluEssentials.getInstance().getProtectionAPI().getProtectionEntry(location); + if (protection == null){ - return false; + if(locationOtherSide == null){ + return false; + } + else{ + protection = RelluEssentials.getInstance().getProtectionAPI().getProtectionEntry(locationOtherSide); + } + + if (protection == null){ + return false; + } + else{ + if(isSource){ + return !ProtectionHelper.hasFlag(protection, ProtectionFlags.ALLOW_HOPPER); + } + else{ + return true; + } + } } else{ return !ProtectionHelper.hasFlag(protection, ProtectionFlags.ALLOW_HOPPER);