diff --git a/randomteleport-plugin/src/main/java/de/themoep/randomteleport/RandomTeleport.java b/randomteleport-plugin/src/main/java/de/themoep/randomteleport/RandomTeleport.java index 6e2e7ed..feef17c 100644 --- a/randomteleport-plugin/src/main/java/de/themoep/randomteleport/RandomTeleport.java +++ b/randomteleport-plugin/src/main/java/de/themoep/randomteleport/RandomTeleport.java @@ -206,6 +206,13 @@ public class RandomTeleport extends JavaPlugin implements RandomTeleportAPI { } return false; })); + addOptionParser(new SimpleOptionParser(array("t", "tries"), (searcher, args) -> { + if (args.length > 0) { + searcher.setMaxTries(Integer.parseInt(args[0])); + return true; + } + return false; + })); addOptionParser(new AdditionalOptionParser("spawnpoint", "sp")); } diff --git a/randomteleport-plugin/src/main/java/de/themoep/randomteleport/searcher/RandomSearcher.java b/randomteleport-plugin/src/main/java/de/themoep/randomteleport/searcher/RandomSearcher.java index 21e6ae6..7aa9dc2 100644 --- a/randomteleport-plugin/src/main/java/de/themoep/randomteleport/searcher/RandomSearcher.java +++ b/randomteleport-plugin/src/main/java/de/themoep/randomteleport/searcher/RandomSearcher.java @@ -65,7 +65,7 @@ public class RandomSearcher { private int minRadius = 0; private int maxRadius = Integer.MAX_VALUE; private boolean generatedOnly = false; - private int maxChecks = 100; + private int maxTries = 100; private int cooldown; private Map options = new LinkedHashMap<>(); @@ -220,12 +220,12 @@ public class RandomSearcher { this.generatedOnly = generatedOnly; } - public int getMaxChecks() { - return maxChecks; + public int getMaxTries() { + return maxTries; } - public void setMaxChecks(int maxChecks) { - this.maxChecks = maxChecks; + public void setMaxTries(int maxTries) { + this.maxTries = maxTries; } /** @@ -266,7 +266,7 @@ public class RandomSearcher { } private void checkRandom(CompletableFuture future) { - if (checks >= maxChecks) { + if (checks >= maxTries) { future.completeExceptionally(new NotFoundException("location")); return; } @@ -359,7 +359,7 @@ public class RandomSearcher { ", minRadius=" + minRadius + ", maxRadius=" + maxRadius + ", generatedOnly=" + generatedOnly + - ", maxChecks=" + maxChecks + + ", maxTries=" + maxTries + ", cooldown=" + cooldown + '}'; } diff --git a/randomteleport-plugin/src/main/resources/plugin.yml b/randomteleport-plugin/src/main/resources/plugin.yml index b0e590c..61d1c62 100644 --- a/randomteleport-plugin/src/main/resources/plugin.yml +++ b/randomteleport-plugin/src/main/resources/plugin.yml @@ -26,6 +26,7 @@ commands: > -id - The ID to use for the cooldown, uses automatically generated one if not provided > -f,-force - teleport even if there is no dirt/grass/sand/gravel, only checks for lava/water/cactus, ignores WorldGuard/Faction regions > -f,-force [] - only ignore blocks or regions + > -t,-tries - the amount of times the plugin should try to find a random location before giving up > -sp,spawnpoint [force] - set the respawn point of the player to the location he teleported to (force overrides existing spawnpoint) / --stat - shows a statistic of the teleports since the last restart / --reload - reloads the config