diff --git a/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/chunklimits/BlockLimit.java b/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/chunklimits/BlockLimit.java index 5fc0429b..7bf2cdc0 100755 --- a/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/chunklimits/BlockLimit.java +++ b/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/chunklimits/BlockLimit.java @@ -9,7 +9,10 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; +import org.bukkit.event.block.Action; +import org.bukkit.event.block.BlockDispenseEvent; import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.player.PlayerInteractEvent; import java.util.EnumMap; import java.util.Map; @@ -153,10 +156,18 @@ public void disable() { @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) private void onBlockPlace(BlockPlaceEvent event) { - if ( - blockLimits.containsKey(event.getBlock().getType()) - && exceedsPerChunkLimit(event.getBlock().getType(), event.getBlock().getChunk()) - ) { + if (blockLimits.containsKey(event.getBlock().getType()) + && exceedsPerChunkLimit(event.getBlock().getType(), event.getBlock().getChunk())) { + event.setCancelled(true); + } + } + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + private void onPlayerInteract(PlayerInteractEvent event) { + if (event.getAction().isLeftClick()) return; + + if (blockLimits.containsKey(event.getMaterial()) + && exceedsPerChunkLimit(event.getMaterial(), event.getPlayer().getChunk())) { event.setCancelled(true); } } diff --git a/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/chunklimits/BlockLimit.java b/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/chunklimits/BlockLimit.java index d5bb97a0..5365c1ba 100755 --- a/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/chunklimits/BlockLimit.java +++ b/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/chunklimits/BlockLimit.java @@ -10,7 +10,9 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; +import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.player.PlayerInteractEvent; import java.util.EnumMap; import java.util.Map; @@ -154,10 +156,18 @@ public void disable() { @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) private void onBlockPlace(BlockPlaceEvent event) { - if ( - blockLimits.containsKey(event.getBlock().getType()) - && exceedsPerChunkLimit(event.getBlock().getType(), event.getBlock().getChunk()) - ) { + if (blockLimits.containsKey(event.getBlock().getType()) + && exceedsPerChunkLimit(event.getBlock().getType(), event.getBlock().getChunk())) { + event.setCancelled(true); + } + } + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + private void onPlayerInteract(PlayerInteractEvent event) { + if (event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK) return; + + if (blockLimits.containsKey(event.getMaterial()) + && exceedsPerChunkLimit(event.getMaterial(), event.getPlayer().getChunk())) { event.setCancelled(true); } }