diff --git a/src/main/java/net/knarcraft/clearonworldguard/listener/PlayerListener.java b/src/main/java/net/knarcraft/clearonworldguard/listener/PlayerListener.java index 833cab3..2c90931 100644 --- a/src/main/java/net/knarcraft/clearonworldguard/listener/PlayerListener.java +++ b/src/main/java/net/knarcraft/clearonworldguard/listener/PlayerListener.java @@ -18,6 +18,7 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.block.Action; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.PlayerLeashEntityEvent; +import org.bukkit.event.player.PlayerBucketEmptyEvent; import org.bukkit.event.player.PlayerChangedWorldEvent; import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; @@ -177,8 +178,16 @@ public class PlayerListener extends WorldGuardListener { if (meta instanceof SpawnEggMeta && !player.hasPermission(Permission.BYPASS_MOB_SPAWNING.toString())) { ClearOnWorldGuard.logDebugMessage("Prevented player " + player + " from using the spawn egg " + item); event.setCancelled(true); + return; } } + + /* Block usage of ender chests while in a clear region (the first check is this method takes care of the case + where the chest is outside the clear region) */ + if (clicked != null && PlayerRegionTracker.isInClearRegion(player) && + event.getAction() != Action.LEFT_CLICK_BLOCK && clicked.getType() == Material.ENDER_CHEST) { + event.setCancelled(true); + } } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @@ -197,4 +206,11 @@ public class PlayerListener extends WorldGuardListener { } } + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onBucketEmpty(@NotNull PlayerBucketEmptyEvent event) { + if (PlayerRegionTracker.isInClearRegion(event.getPlayer())) { + event.setCancelled(true); + } + } + }