Skip to content

Commit

Permalink
limit how far the y-coordinate will be expanded
Browse files Browse the repository at this point in the history
  • Loading branch information
HSGamer committed Dec 19, 2021
1 parent f91ed47 commit 168de62
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
15 changes: 15 additions & 0 deletions src/main/java/world/bentobox/bentobox/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,13 @@ public class Settings implements ConfigObject {
@ConfigEntry(path = "island.deletion.keep-previous-island-on-reset", since = "1.13.0")
private boolean keepPreviousIslandOnReset = false;

@ConfigComment("By default, If the destination is not safe, the plugin will try to search for a safe spot around the destination,")
@ConfigComment("then it will try to expand the y-coordinate up and down from the destination.")
@ConfigComment("This setting limits how far the y-coordinate will be expanded.")
@ConfigComment("If set to 0 or lower, the plugin will not expand the y-coordinate.")
@ConfigEntry(path = "island.safe-spot-search-vertical-range", since = "1.19.1")
private int safeSpotSearchVerticalRange = 400;

/* WEB */
@ConfigComment("Toggle whether BentoBox can connect to GitHub to get data about updates and addons.")
@ConfigComment("Disabling this will result in the deactivation of the update checker and of some other")
Expand Down Expand Up @@ -890,4 +897,12 @@ public int getMinPortalSearchRadius() {
public void setMinPortalSearchRadius(int minPortalSearchRadius) {
this.minPortalSearchRadius = minPortalSearchRadius;
}

public int getSafeSpotSearchVerticalRange() {
return safeSpotSearchVerticalRange;
}

public void setSafeSpotSearchVerticalRange(int safeSpotSearchVerticalRange) {
this.safeSpotSearchVerticalRange = safeSpotSearchVerticalRange;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,8 @@ private boolean scanChunk(ChunkSnapshot chunk) {
int lowerY = startY - 1;
boolean checkUpper = upperY <= maxY;
boolean checkLower = lowerY >= minY;
while (checkUpper || checkLower) {
int limitRange = plugin.getSettings().getSafeSpotSearchVerticalRange(); // Limit the y-coordinate range
while (limitRange > 0 && (checkUpper || checkLower)) {
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
if (checkUpper && checkBlock(chunk, x, upperY, z)) {
Expand All @@ -268,6 +269,7 @@ private boolean scanChunk(ChunkSnapshot chunk) {
checkLower = false;
}
}
limitRange--;
}

// We can't find a safe spot
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,12 @@ island:
# This is the default behaviour.
# Added since 1.13.0.
keep-previous-island-on-reset: false
# By default, If the destination is not safe, the plugin will try to search for a safe spot around the destination,
# then it will try to expand the y-coordinate up and down from the destination.
# This setting limits how far the y-coordinate will be expanded.
# If set to 0 or lower, the plugin will not expand the y-coordinate.
# Added since 1.19.1.
safe-spot-search-vertical-range: 400
web:
github:
# Toggle whether BentoBox can connect to GitHub to get data about updates and addons.
Expand Down

0 comments on commit 168de62

Please sign in to comment.