From 2c7f5f98ad4f7e75e77a135b3ef02b252fe20c76 Mon Sep 17 00:00:00 2001 From: Marcos Paulo Date: Thu, 20 Aug 2026 10:21:11 -0300 Subject: [PATCH] fix(review): check event.getKeepInventory(), equipment slot hand, and world height bounds --- .../dev/marcospaulo/canalhandia/Canalhandia.java | 2 +- .../canalhandia/ChunkLoaderListener.java | 3 +++ .../dev/marcospaulo/canalhandia/VoidProtection.java | 13 ++++++++++--- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/main/java/dev/marcospaulo/canalhandia/Canalhandia.java b/src/main/java/dev/marcospaulo/canalhandia/Canalhandia.java index 036727c..fc49c5b 100644 --- a/src/main/java/dev/marcospaulo/canalhandia/Canalhandia.java +++ b/src/main/java/dev/marcospaulo/canalhandia/Canalhandia.java @@ -934,7 +934,7 @@ public final class Canalhandia extends JavaPlugin implements Listener { Location loc = player.getLocation(); String coords = loc.getBlockX() + " " + loc.getBlockY() + " " + loc.getBlockZ() + " (" + loc.getWorld().getName() + ")"; - boolean keepInventory = Boolean.TRUE.equals( + boolean keepInventory = event.getKeepInventory() || Boolean.TRUE.equals( loc.getWorld().getGameRuleValue(GameRule.KEEP_INVENTORY)); pendingDeathCoords.put(player.getUniqueId(), new DeathCoords(coords, keepInventory)); diff --git a/src/main/java/dev/marcospaulo/canalhandia/ChunkLoaderListener.java b/src/main/java/dev/marcospaulo/canalhandia/ChunkLoaderListener.java index bb2e30f..a0ccc58 100644 --- a/src/main/java/dev/marcospaulo/canalhandia/ChunkLoaderListener.java +++ b/src/main/java/dev/marcospaulo/canalhandia/ChunkLoaderListener.java @@ -149,6 +149,9 @@ final class ChunkLoaderListener implements Listener { if (!plugin.settings().moduleEnabled(Module.CHUNKLOADER)) { return; } + if (event.getHand() != org.bukkit.inventory.EquipmentSlot.HAND) { + return; + } if (event.getAction() != Action.RIGHT_CLICK_BLOCK) { return; } diff --git a/src/main/java/dev/marcospaulo/canalhandia/VoidProtection.java b/src/main/java/dev/marcospaulo/canalhandia/VoidProtection.java index 4cccc36..6191934 100644 --- a/src/main/java/dev/marcospaulo/canalhandia/VoidProtection.java +++ b/src/main/java/dev/marcospaulo/canalhandia/VoidProtection.java @@ -77,12 +77,19 @@ public final class VoidProtection { continue; } - if (topY <= minHeight) { + int maxHeight = world.getMaxHeight(); + if (topY <= minHeight || topY >= maxHeight - 1) { continue; } - Block ground = world.getBlockAt(x, topY, z); - Block space = world.getBlockAt(x, topY + 1, z); + Block ground; + Block space; + try { + ground = world.getBlockAt(x, topY, z); + space = world.getBlockAt(x, topY + 1, z); + } catch (Exception e) { + continue; + } if (isSafeGround(ground) && isReplaceable(space)) { double distSq = (dx * dx) + (dz * dz);