Skip to content

Commit

Permalink
Merge pull request #185 from ImNotSoftik/master
Browse files Browse the repository at this point in the history
More configuration for PreventGoingBelowBedrockFloor
  • Loading branch information
xGinko authored Feb 12, 2024
2 parents da9c8cc + 1ff07a5 commit a11754f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,19 @@ public class PreventGoingBelowBedrockFloor implements AnarchyExploitFixesModule,

private final Set<String> exemptedWorlds;
private final Material fillMaterial;
private final boolean teleport_enabled;
private final boolean filling_enabled;
private final boolean eject_enabled;
private final boolean stop_elytra_enabled;

public PreventGoingBelowBedrockFloor() {
shouldEnable();
Config config = AnarchyExploitFixes.getConfiguration();
config.addComment("bedrock.prevent-going-below-bedrock-floor.enable", "Fills the bedrock hole and teleports player above.");
config.addComment("bedrock.prevent-going-below-bedrock-floor.enable", "Prevents the player from being hit by a bedrock");
this.teleport_enabled = config.getBoolean("bedrock.prevent-going-below-bedrock-floor.teleport", true, "Teleports the player above the bedrock");
this.eject_enabled = config.getBoolean("bedrock.prevent-going-below-bedrock-floor.eject-player", true, "Eject player from the vehicle");
this.stop_elytra_enabled = config.getBoolean("bedrock.prevent-going-below-bedrock-floor.stop-elytra", true, "Disables a player's elytra flight");
this.filling_enabled = config.getBoolean("bedrock.prevent-going-below-bedrock-floor.fill-bedrock-hole", true, "Indicates whether the hole should be filled from bedorck");
this.exemptedWorlds = new HashSet<>(config.getList("bedrock.prevent-going-below-bedrock-floor.exempted-worlds", List.of("world_the_end", "skyblock_world")));
String configuredFillMaterial = config.getString("bedrock.prevent-going-below-bedrock-floor.filler-material", "BEDROCK");
Material filler_material = Material.BEDROCK;
Expand Down Expand Up @@ -75,9 +83,11 @@ private void onPlayerMove(PlayerMoveEvent event) {

if (playerLoc.getY() < world.getMinHeight()) {
// place bedrock at the min world height
world.getBlockAt(playerLoc.getBlockX(), world.getMinHeight(), playerLoc.getBlockZ()).setType(fillMaterial);
if (filling_enabled) world.getBlockAt(playerLoc.getBlockX(), world.getMinHeight(), playerLoc.getBlockZ()).setType(fillMaterial);
// teleport player on top of that bedrock
event.setTo(event.getFrom().add(0, 2, 0));
if (teleport_enabled) event.setTo(event.getFrom().add(0, 2, 0));
if (eject_enabled && player.isInsideVehicle()) player.leaveVehicle();
if (stop_elytra_enabled && player.isGliding()) player.setGliding(false);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,19 @@ public class PreventGoingBelowBedrockFloor implements AnarchyExploitFixesModule,

private final Set<String> exemptedWorlds;
private final Material fillMaterial;
private final boolean teleport_enabled;
private final boolean filling_enabled;
private final boolean eject_enabled;
private final boolean stop_elytra_enabled;

public PreventGoingBelowBedrockFloor() {
shouldEnable();
Config config = AnarchyExploitFixes.getConfiguration();
config.addComment("bedrock.prevent-going-below-bedrock-floor.enable", "Fills the bedrock hole and teleports player above.");
this.teleport_enabled = config.getBoolean("bedrock.prevent-going-below-bedrock-floor.teleport", true, "Teleports the player above the bedrock");
this.eject_enabled = config.getBoolean("bedrock.prevent-going-below-bedrock-floor.eject-player", true, "Eject player from the vehicle");
this.stop_elytra_enabled = config.getBoolean("bedrock.prevent-going-below-bedrock-floor.stop-elytra", true, "Disables a player's elytra flight");
this.filling_enabled = config.getBoolean("bedrock.prevent-going-below-bedrock-floor.fill-bedrock-hole", true, "Indicates whether the hole should be filled from bedorck");
this.exemptedWorlds = new HashSet<>(config.getList("bedrock.prevent-going-below-bedrock-floor.exempted-worlds", Arrays.asList("world_the_end", "skyblock_world")));
String configuredFillMaterial = config.getString("bedrock.prevent-going-below-bedrock-floor.filler-material", "BEDROCK");
Material filler_material = Material.BEDROCK;
Expand Down Expand Up @@ -71,9 +79,11 @@ private void onPlayerMove(PlayerMoveEvent event) {

if (playerLoc.getY() < ChunkUtil.guessMinWorldHeight(world)) {
// place bedrock at the min world height
world.getBlockAt(playerLoc.getBlockX(), ChunkUtil.guessMinWorldHeight(world), playerLoc.getBlockZ()).setType(fillMaterial);
if (filling_enabled) world.getBlockAt(playerLoc.getBlockX(), ChunkUtil.guessMinWorldHeight(world), playerLoc.getBlockZ()).setType(fillMaterial);
// teleport player on top of that bedrock
event.setTo(event.getFrom().add(0, 2, 0));
if (teleport_enabled) event.setTo(event.getFrom().add(0, 2, 0));
if (eject_enabled && player.isInsideVehicle()) player.leaveVehicle();
if (stop_elytra_enabled && player.isGliding()) player.setGliding(false);
}
}
}

0 comments on commit a11754f

Please sign in to comment.