From 337defb4524b2077d50c4aed3c99d5b7b0ac9344 Mon Sep 17 00:00:00 2001 From: BONNe Date: Sun, 21 Apr 2019 10:13:41 +0300 Subject: [PATCH] Add protective code that prevents for setting search radius too large. Now it will be caped at island radius. --- .../bentobox/challenges/panel/admin/EditChallengeGUI.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/world/bentobox/challenges/panel/admin/EditChallengeGUI.java b/src/main/java/world/bentobox/challenges/panel/admin/EditChallengeGUI.java index f67165b..788886d 100644 --- a/src/main/java/world/bentobox/challenges/panel/admin/EditChallengeGUI.java +++ b/src/main/java/world/bentobox/challenges/panel/admin/EditChallengeGUI.java @@ -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);