From 1ecbac43bf5a7e433975be43f1c477f0426c9b08 Mon Sep 17 00:00:00 2001 From: BONNe Date: Fri, 18 Jan 2019 19:26:03 +0200 Subject: [PATCH] Add last missing element in AdminGUI. Now AdminGUI all icons are functional. --- .../challenges/ChallengesManager.java | 24 +++++++++ .../challenges/panel/admin/AdminGUI.java | 49 ++++++++++++++++++- 2 files changed, 71 insertions(+), 2 deletions(-) diff --git a/src/main/java/world/bentobox/challenges/ChallengesManager.java b/src/main/java/world/bentobox/challenges/ChallengesManager.java index f61e0cd..4d03187 100644 --- a/src/main/java/world/bentobox/challenges/ChallengesManager.java +++ b/src/main/java/world/bentobox/challenges/ChallengesManager.java @@ -544,4 +544,28 @@ public class ChallengesManager { { } + + + public Challenges createChallenge(String reply) + { + return new Challenges(); + } + + + public boolean validateChallengeUniqueID(World world, String reply) + { + return false; + } + + + public boolean validateLevelUniqueID(World world, String reply) + { + return false; + } + + + public ChallengeLevels createLevel(String reply) + { + return new ChallengeLevels(); + } } diff --git a/src/main/java/world/bentobox/challenges/panel/admin/AdminGUI.java b/src/main/java/world/bentobox/challenges/panel/admin/AdminGUI.java index 2893d6f..273a161 100644 --- a/src/main/java/world/bentobox/challenges/panel/admin/AdminGUI.java +++ b/src/main/java/world/bentobox/challenges/panel/admin/AdminGUI.java @@ -7,6 +7,7 @@ import org.bukkit.inventory.ItemStack; import java.util.Collections; import java.util.List; +import net.wesjd.anvilgui.AnvilGUI; import world.bentobox.bentobox.api.panels.PanelItem; import world.bentobox.bentobox.api.panels.builders.PanelBuilder; import world.bentobox.bentobox.api.user.User; @@ -189,7 +190,29 @@ public class AdminGUI extends CommonGUI description = Collections.emptyList(); icon = new ItemStack(Material.BOOK); clickHandler = (panel, user, clickType, slot) -> { - // TODO: Create AnvilGUI that force to create String for "unique_id" + new AnvilGUI(this.addon.getPlugin(), + this.user.getPlayer(), + "unique_id", + (player, reply) -> { + + if (this.addon.getChallengesManager().validateChallengeUniqueID(this.world, reply)) + { + new EditChallengeGUI(this.addon, + this.world, + this.user, + this.addon.getChallengesManager().createChallenge(reply), + this.topLabel, + this.permissionPrefix, + this).build(); + } + else + { + // TODO: Throw message that uniqueID is not valid. + this.build(); + } + + return reply; + }); return true; }; @@ -203,7 +226,29 @@ public class AdminGUI extends CommonGUI description = Collections.emptyList(); icon = new ItemStack(Material.BOOK); clickHandler = (panel, user, clickType, slot) -> { - // TODO: Create AnvilGUI that force to create String for "unique_id" + new AnvilGUI(this.addon.getPlugin(), + this.user.getPlayer(), + "unique_id", + (player, reply) -> { + + if (this.addon.getChallengesManager().validateLevelUniqueID(this.world, reply)) + { + new EditLevelGUI(this.addon, + this.world, + this.user, + this.addon.getChallengesManager().createLevel(reply), + this.topLabel, + this.permissionPrefix, + this).build(); + } + else + { + // TODO: Throw message that uniqueID is not valid. + this.build(); + } + + return reply; + }); return true; };