fix(review): check event.getKeepInventory(), equipment slot hand, and world height bounds
This commit is contained in:
@@ -934,7 +934,7 @@ public final class Canalhandia extends JavaPlugin implements Listener {
|
|||||||
Location loc = player.getLocation();
|
Location loc = player.getLocation();
|
||||||
String coords = loc.getBlockX() + " " + loc.getBlockY() + " " + loc.getBlockZ()
|
String coords = loc.getBlockX() + " " + loc.getBlockY() + " " + loc.getBlockZ()
|
||||||
+ " (" + loc.getWorld().getName() + ")";
|
+ " (" + loc.getWorld().getName() + ")";
|
||||||
boolean keepInventory = Boolean.TRUE.equals(
|
boolean keepInventory = event.getKeepInventory() || Boolean.TRUE.equals(
|
||||||
loc.getWorld().getGameRuleValue(GameRule.KEEP_INVENTORY));
|
loc.getWorld().getGameRuleValue(GameRule.KEEP_INVENTORY));
|
||||||
pendingDeathCoords.put(player.getUniqueId(), new DeathCoords(coords, keepInventory));
|
pendingDeathCoords.put(player.getUniqueId(), new DeathCoords(coords, keepInventory));
|
||||||
|
|
||||||
|
|||||||
@@ -149,6 +149,9 @@ final class ChunkLoaderListener implements Listener {
|
|||||||
if (!plugin.settings().moduleEnabled(Module.CHUNKLOADER)) {
|
if (!plugin.settings().moduleEnabled(Module.CHUNKLOADER)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (event.getHand() != org.bukkit.inventory.EquipmentSlot.HAND) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK) {
|
if (event.getAction() != Action.RIGHT_CLICK_BLOCK) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,12 +77,19 @@ public final class VoidProtection {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (topY <= minHeight) {
|
int maxHeight = world.getMaxHeight();
|
||||||
|
if (topY <= minHeight || topY >= maxHeight - 1) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Block ground = world.getBlockAt(x, topY, z);
|
Block ground;
|
||||||
Block space = world.getBlockAt(x, topY + 1, z);
|
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)) {
|
if (isSafeGround(ground) && isReplaceable(space)) {
|
||||||
double distSq = (dx * dx) + (dz * dz);
|
double distSq = (dx * dx) + (dz * dz);
|
||||||
|
|||||||
Reference in New Issue
Block a user