Add protective code that prevents for setting search radius too large.

Now it will be caped at island radius.
This commit is contained in:
BONNe 2019-04-21 10:13:41 +03:00
parent 6395064cbb
commit 337defb452
1 changed files with 7 additions and 1 deletions

View File

@ -654,8 +654,14 @@ public class EditChallengeGUI extends CommonGUI
"[value]", Integer.toString(this.challenge.getSearchRadius())));
icon = new ItemStack(Material.COBBLESTONE_WALL);
// Search radius should not be larger then island radius.
int maxSearchDistance =
this.addon.getPlugin().getIWM().getAddon(this.world).map(gameModeAddon ->
gameModeAddon.getWorldSettings().getIslandDistance()).orElse(100);
clickHandler = (panel, user, clickType, slot) -> {
new NumberGUI(this.user, this.challenge.getSearchRadius(), 0, lineLength, (status, value) -> {
new NumberGUI(this.user, this.challenge.getSearchRadius(), 0, maxSearchDistance, lineLength, (status, value) -> {
if (status)
{
this.challenge.setSearchRadius(value);