From a55e3764a786a0fda645441e77be080a77f737f6 Mon Sep 17 00:00:00 2001 From: moo <48740106+moom0o@users.noreply.github.com> Date: Tue, 14 Dec 2021 22:42:26 -0500 Subject: [PATCH] 1.18 Hotfix - Fix minimum height. --- pom.xml | 2 +- .../anarchyexploitfixes/patches/CrashExploits.java | 10 +++++++++- .../moomoo/anarchyexploitfixes/patches/Elytra.java | 12 ++++++++++-- 3 files changed, 20 insertions(+), 4 deletions(-) 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; + } + } }