Skip to content

Commit

Permalink
1.18 Hotfix - Fix minimum height.
Browse files Browse the repository at this point in the history
  • Loading branch information
moom0o committed Dec 15, 2021
1 parent 01dd770 commit a55e376
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>me.moomoo</groupId>
<artifactId>anarchyexploitfixes</artifactId>
<version>1.21.1</version>
<version>1.21.2</version>
<packaging>jar</packaging>

<name>AnarchyExploitFixes</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
12 changes: 10 additions & 2 deletions src/main/java/me/moomoo/anarchyexploitfixes/patches/Elytra.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
Expand Down Expand Up @@ -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;
}
}
}

0 comments on commit a55e376

Please sign in to comment.