diff --git a/pom.xml b/pom.xml index ca1d91ba6..a4c739bc2 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ me.moomoo anarchyexploitfixes - 1.21.1 + 1.21.2 jar AnarchyExploitFixes diff --git a/src/main/java/me/moomoo/anarchyexploitfixes/patches/CrashExploits.java b/src/main/java/me/moomoo/anarchyexploitfixes/patches/CrashExploits.java index 153cbfef0..97fe191b4 100644 --- a/src/main/java/me/moomoo/anarchyexploitfixes/patches/CrashExploits.java +++ b/src/main/java/me/moomoo/anarchyexploitfixes/patches/CrashExploits.java @@ -34,9 +34,17 @@ private void onEntityTeleportEvent(EntityTeleportEvent evt) { @EventHandler private void onDispense(BlockDispenseEvent evt) { - if (plugin.getConfig().getBoolean("PreventDispenserCrashExploit") && (evt.getBlock().getLocation().getY() >= evt.getBlock().getWorld().getMaxHeight() - 1 || evt.getBlock().getLocation().getY() <= 0)) { + if (plugin.getConfig().getBoolean("PreventDispenserCrashExploit") && (evt.getBlock().getLocation().getY() >= evt.getBlock().getWorld().getMaxHeight() - 1 || evt.getBlock().getLocation().getY() <= getMinimumHeight())) { evt.setCancelled(true); plugin.getLogger().warning("Prevented a dispenser from crashing the server at " + evt.getBlock().getLocation()); } } + + private Integer getMinimumHeight() { + if (plugin.getServer().getWorlds().get(0).getMaxHeight() <= 256) { + return 0; + } else { + return -64; + } + } } diff --git a/src/main/java/me/moomoo/anarchyexploitfixes/patches/Elytra.java b/src/main/java/me/moomoo/anarchyexploitfixes/patches/Elytra.java index 1745fd0ed..6d67f72a6 100644 --- a/src/main/java/me/moomoo/anarchyexploitfixes/patches/Elytra.java +++ b/src/main/java/me/moomoo/anarchyexploitfixes/patches/Elytra.java @@ -40,9 +40,9 @@ private void onMove(PlayerMoveEvent evt) { } if (config.getBoolean("PreventGoingBelowBedrockFloor")) { - if (evt.getPlayer().getLocation().getY() < 0) { + if (evt.getPlayer().getLocation().getY() < getMinimumHeight()) { if (!evt.getPlayer().getWorld().getEnvironment().equals(World.Environment.THE_END)) { - evt.getPlayer().getWorld().getBlockAt(evt.getPlayer().getLocation().getBlockX(), 0, evt.getPlayer().getLocation().getBlockZ()).setType(Material.BEDROCK); + evt.getPlayer().getWorld().getBlockAt(evt.getPlayer().getLocation().getBlockX(), getMinimumHeight(), evt.getPlayer().getLocation().getBlockZ()).setType(Material.BEDROCK); evt.setTo(evt.getFrom().add(0, 2, 0)); } } @@ -200,4 +200,12 @@ public void onOpen(EntityToggleGlideEvent evt) { } } } + + private Integer getMinimumHeight() { + if (plugin.getServer().getWorlds().get(0).getMaxHeight() <= 256) { + return 0; + } else { + return -64; + } + } }