From c05015716f2d9b8dc966736e24ac7c9c52cc33c1 Mon Sep 17 00:00:00 2001 From: BONNe Date: Fri, 26 Apr 2019 21:27:52 +0300 Subject: [PATCH] Enable Level and Money editing, even when required addons or plugins are not provided. --- .../panel/admin/EditChallengeGUI.java | 149 +++++++----------- .../challenges/panel/admin/EditLevelGUI.java | 30 ++-- 2 files changed, 66 insertions(+), 113 deletions(-) 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 f258d4b..1a158ea 100644 --- a/src/main/java/world/bentobox/challenges/panel/admin/EditChallengeGUI.java +++ b/src/main/java/world/bentobox/challenges/panel/admin/EditChallengeGUI.java @@ -824,27 +824,19 @@ public class EditChallengeGUI extends CommonGUI description.add(this.user.getTranslation("challenges.gui.descriptions.current-value", "[value]", Long.toString(this.challenge.getRequiredIslandLevel()))); - if (this.addon.isLevelProvided()) - { - icon = new ItemStack(Material.BEACON); - clickHandler = (panel, user, clickType, slot) -> { - new NumberGUI(this.user, (int) this.challenge.getRequiredIslandLevel(), lineLength, (status, value) -> { - if (status) - { - this.challenge.setRequiredIslandLevel(value); - } + icon = new ItemStack(this.addon.isLevelProvided() ? Material.BEACON : Material.BARRIER); + clickHandler = (panel, user, clickType, slot) -> { + new NumberGUI(this.user, (int) this.challenge.getRequiredIslandLevel(), lineLength, (status, value) -> { + if (status) + { + this.challenge.setRequiredIslandLevel(value); + } - this.build(); - }); + this.build(); + }); - return true; - }; - } - else - { - icon = new ItemStack(Material.BARRIER); - clickHandler = null; - } + return true; + }; glow = false; break; @@ -857,26 +849,18 @@ public class EditChallengeGUI extends CommonGUI description.add(this.user.getTranslation("challenges.gui.descriptions.current-value", "[value]", Long.toString(this.challenge.getRequiredIslandLevel()))); - if (this.addon.isEconomyProvided()) - { - icon = new ItemStack(Material.GOLD_INGOT); - clickHandler = (panel, user, clickType, slot) -> { - new NumberGUI(this.user, this.challenge.getRequiredMoney(), 0, lineLength, (status, value) -> { - if (status) - { - this.challenge.setRequiredMoney(value); - } + icon = new ItemStack(this.addon.isEconomyProvided() ? Material.GOLD_INGOT : Material.BARRIER); + clickHandler = (panel, user, clickType, slot) -> { + new NumberGUI(this.user, this.challenge.getRequiredMoney(), 0, lineLength, (status, value) -> { + if (status) + { + this.challenge.setRequiredMoney(value); + } - this.build(); - }); - return true; - }; - } - else - { - icon = new ItemStack(Material.BARRIER); - clickHandler = null; - } + this.build(); + }); + return true; + }; glow = false; break; @@ -892,21 +876,13 @@ public class EditChallengeGUI extends CommonGUI this.user.getTranslation("challenges.gui.descriptions.enabled") : this.user.getTranslation("challenges.gui.descriptions.disabled"))); - if (this.addon.isEconomyProvided()) - { - icon = new ItemStack(Material.LEVER); - clickHandler = (panel, user, clickType, slot) -> { - this.challenge.setTakeMoney(!this.challenge.isTakeMoney()); + icon = new ItemStack(this.addon.isEconomyProvided() ? Material.LEVER : Material.BARRIER); + clickHandler = (panel, user, clickType, slot) -> { + this.challenge.setTakeMoney(!this.challenge.isTakeMoney()); - this.build(); - return true; - }; - } - else - { - icon = new ItemStack(Material.BARRIER); - clickHandler = null; - } + this.build(); + return true; + }; glow = this.challenge.isTakeMoney(); break; @@ -1009,27 +985,20 @@ public class EditChallengeGUI extends CommonGUI description.add(this.user.getTranslation("challenges.gui.descriptions.current-value", "[value]", Integer.toString(this.challenge.getRewardMoney()))); - if (this.addon.isEconomyProvided()) - { - icon = new ItemStack(Material.GOLD_INGOT); - clickHandler = (panel, user, clickType, slot) -> { - new NumberGUI(this.user, this.challenge.getRewardMoney(), 0, lineLength, (status, value) -> { - if (status) - { - this.challenge.setRewardMoney(value); - } + icon = new ItemStack(this.addon.isEconomyProvided() ? Material.GOLD_INGOT : Material.BARRIER); + clickHandler = (panel, user, clickType, slot) -> { + new NumberGUI(this.user, this.challenge.getRewardMoney(), 0, lineLength, (status, value) -> { + if (status) + { + this.challenge.setRewardMoney(value); + } - this.build(); - }); + this.build(); + }); + + return true; + }; - return true; - }; - } - else - { - icon = new ItemStack(Material.BARRIER); - clickHandler = null; - } glow = false; break; @@ -1207,31 +1176,23 @@ public class EditChallengeGUI extends CommonGUI description.add(this.user.getTranslation("challenges.gui.descriptions.current-value", "[value]", Integer.toString(this.challenge.getRepeatMoneyReward()))); - if (this.addon.isEconomyProvided()) - { - icon = new ItemStack(Material.GOLD_NUGGET); - clickHandler = (panel, user, clickType, slot) -> { - new NumberGUI(this.user, - this.challenge.getRepeatMoneyReward(), - 0, - lineLength, - (status, value) -> { - if (status) - { - this.challenge.setRepeatMoneyReward(value); - } + icon = new ItemStack(this.addon.isEconomyProvided() ? Material.GOLD_NUGGET : Material.BARRIER); + clickHandler = (panel, user, clickType, slot) -> { + new NumberGUI(this.user, + this.challenge.getRepeatMoneyReward(), + 0, + lineLength, + (status, value) -> { + if (status) + { + this.challenge.setRepeatMoneyReward(value); + } - this.build(); - }); + this.build(); + }); - return true; - }; - } - else - { - icon = new ItemStack(Material.BARRIER); - clickHandler = null; - } + return true; + }; glow = false; break; diff --git a/src/main/java/world/bentobox/challenges/panel/admin/EditLevelGUI.java b/src/main/java/world/bentobox/challenges/panel/admin/EditLevelGUI.java index 91fbdd6..175c2a3 100644 --- a/src/main/java/world/bentobox/challenges/panel/admin/EditLevelGUI.java +++ b/src/main/java/world/bentobox/challenges/panel/admin/EditLevelGUI.java @@ -584,27 +584,19 @@ public class EditLevelGUI extends CommonGUI description.add(this.user.getTranslation("challenges.gui.descriptions.current-value", "[value]", Integer.toString(this.challengeLevel.getRewardMoney()))); - if (this.addon.isEconomyProvided()) - { - icon = new ItemStack(Material.GOLD_INGOT); - clickHandler = (panel, user, clickType, slot) -> { - new NumberGUI(this.user, this.challengeLevel.getRewardMoney(), 0, lineLength, (status, value) -> { - if (status) - { - this.challengeLevel.setRewardMoney(value); - } + icon = new ItemStack(this.addon.isEconomyProvided() ? Material.GOLD_INGOT : Material.BARRIER); + clickHandler = (panel, user, clickType, slot) -> { + new NumberGUI(this.user, this.challengeLevel.getRewardMoney(), 0, lineLength, (status, value) -> { + if (status) + { + this.challengeLevel.setRewardMoney(value); + } - this.build(); - }); + this.build(); + }); - return true; - }; - } - else - { - icon = new ItemStack(Material.BARRIER); - clickHandler = null; - } + return true; + }; glow = false; break;