Skip to content

Commit

Permalink
Added the ability to use the {player} placeholder for the minimum and…
Browse files Browse the repository at this point in the history
… maximum y values in the config, to allow breaking of all the blocks above or below the player's y-level for example.
  • Loading branch information
biscuut committed Nov 12, 2018
1 parent 5ae94e2 commit 76adcb4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
26 changes: 22 additions & 4 deletions src/main/java/xyz/biscut/chunkbuster/utils/ConfigValues.java
Original file line number Diff line number Diff line change
Expand Up @@ -367,12 +367,30 @@ public boolean showUpdateMessage() {
return main.getConfig().getBoolean("show-update-messages");
}

public int getMinimumY() {
return main.getConfig().getInt("minimum-y");
public int getMinimumY(Player p) {
if (main.getConfig().getString("minimum-y").toLowerCase().contains("{player}")) {
return (int)p.getLocation().getY();
} else {
try {
return Integer.valueOf(main.getConfig().getString("minimum-y"));
} catch (NumberFormatException ex) {
main.getLogger().warning("Your minimum-y value is invalid, please either change this to an integer or '{player}' in the config.");
return 0;
}
}
}

public int getMaximumY() {
return main.getConfig().getInt("maximum-y");
public int getMaximumY(Player p) {
if (main.getConfig().getString("maximum-y").toLowerCase().contains("{player}")) {
return (int)p.getLocation().getY();
} else {
try {
return Integer.valueOf(main.getConfig().getString("maximum-y"));
} catch (NumberFormatException ex) {
main.getLogger().warning("Your maximum-y value is invalid, please either change this to an integer or '{player}' in the config.");
return 255;
}
}
}

public double getConfigVersion() {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/xyz/biscut/chunkbuster/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void clearChunks(int chunkBusterArea, Location chunkBusterLocation, Playe
if (chunkBusterArea == 1) {
RemovalQueue removalQueue = new RemovalQueue(main);
waterChunks.add(chunkBusterLocation.getChunk());
for (int y = main.getConfigValues().getMaximumY(); y >= main.getConfigValues().getMinimumY(); y--) {
for (int y = main.getConfigValues().getMaximumY(p); y >= main.getConfigValues().getMinimumY(p); y--) {
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
Block b = chunkBusterLocation.getChunk().getBlock(x, y, z);
Expand All @@ -64,7 +64,7 @@ public void clearChunks(int chunkBusterArea, Location chunkBusterLocation, Playe
int lowerSearchBound = (chunkBusterArea - 1) / -2;
int startingX = chunkBusterLocation.getChunk().getX();
int startingZ = chunkBusterLocation.getChunk().getZ();
for (int y = main.getConfigValues().getMaximumY(); y >= main.getConfigValues().getMinimumY(); y--) {
for (int y = main.getConfigValues().getMaximumY(p); y >= main.getConfigValues().getMinimumY(p); y--) {
for (int chunkX = lowerSearchBound; chunkX < upperSearchBound; chunkX++) {
for (int chunkZ = lowerSearchBound; chunkZ < upperSearchBound; chunkZ++) {
Chunk chunk = chunkBusterLocation.getWorld().getChunkAt(startingX + chunkX, startingZ + chunkZ);
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ can-place-in-wilderness: true
cooldown: 0

# Chunkbusters clear between this minimum value and the maximum value (both inclusive). 0 and 255 means the whole chunk.
# You can use '{player}' for the player's Y-coordinate.
minimum-y: 0
maximum-y: 255

Expand Down

0 comments on commit 76adcb4

Please sign in to comment.