Skip to content

Commit

Permalink
More configuration for PreventGoingBelowBedrockFloor
Browse files Browse the repository at this point in the history
  • Loading branch information
SoftikGithub committed Feb 10, 2024
1 parent 31ab419 commit 7145939
Showing 1 changed file with 13 additions and 3 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);
}
}
}

0 comments on commit 7145939

Please sign in to comment.