limit how far the y-coordinate will be expanded

This commit is contained in:
Huynh Tien 2021-12-19 20:40:01 +07:00
parent f91ed4705a
commit 168de622ea
3 changed files with 24 additions and 1 deletions

View File

@ -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")
@ -890,4 +897,12 @@ public class Settings implements ConfigObject {
public void setMinPortalSearchRadius(int minPortalSearchRadius) {
this.minPortalSearchRadius = minPortalSearchRadius;
}
public int getSafeSpotSearchVerticalRange() {
return safeSpotSearchVerticalRange;
}
public void setSafeSpotSearchVerticalRange(int safeSpotSearchVerticalRange) {
this.safeSpotSearchVerticalRange = safeSpotSearchVerticalRange;
}
}

View File

@ -245,7 +245,8 @@ public class SafeSpotTeleport {
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)) {
@ -268,6 +269,7 @@ public class SafeSpotTeleport {
checkLower = false;
}
}
limitRange--;
}
// We can't find a safe spot

View File

@ -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.