From 6bf439cef6bc97665ec2a9a571b853b8d8b51f68 Mon Sep 17 00:00:00 2001 From: BONNe Date: Tue, 5 Mar 2019 10:55:44 +0200 Subject: [PATCH] Add Single GUI enabling button in Settings GUI. --- .../panel/admin/EditSettingsGUI.java | 41 ++++++++++++++++--- src/main/resources/locales/en-US.yml | 2 + 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/src/main/java/world/bentobox/challenges/panel/admin/EditSettingsGUI.java b/src/main/java/world/bentobox/challenges/panel/admin/EditSettingsGUI.java index e80af8d..419c145 100644 --- a/src/main/java/world/bentobox/challenges/panel/admin/EditSettingsGUI.java +++ b/src/main/java/world/bentobox/challenges/panel/admin/EditSettingsGUI.java @@ -78,9 +78,16 @@ public class EditSettingsGUI extends CommonGUI panelBuilder.item(20, this.getSettingsButton(Button.GLOW_COMPLETED)); panelBuilder.item(29, this.getSettingsButton(Button.REMOVE_COMPLETED)); - panelBuilder.item(12, this.getSettingsButton(Button.LOCKED_LEVEL_ICON)); - panelBuilder.item(21, this.getSettingsButton(Button.FREE_AT_TOP)); - panelBuilder.item(30, this.getSettingsButton(Button.GAMEMODE_GUI)); + panelBuilder.item(21, this.getSettingsButton(Button.LOCKED_LEVEL_ICON)); + panelBuilder.item(30, this.getSettingsButton(Button.FREE_AT_TOP)); + + panelBuilder.item(22, this.getSettingsButton(Button.GAMEMODE_GUI)); + + if (this.settings.isUseCommonGUI()) + { + // This should be active only when single gui is enabled. + panelBuilder.item(31, this.getSettingsButton(Button.GAMEMODE_GUI_VIEW_MODE)); + } panelBuilder.item(14, this.getSettingsButton(Button.LORE_LENGTH)); panelBuilder.item(23, this.getSettingsButton(Button.CHALLENGE_LORE)); @@ -294,7 +301,7 @@ public class EditSettingsGUI extends CommonGUI glow = this.settings.isAddCompletedGlow(); break; } - case GAMEMODE_GUI: + case GAMEMODE_GUI_VIEW_MODE: { description = new ArrayList<>(2); description.add(this.user.getTranslation("challenges.gui.descriptions.admin.gui-view-mode")); @@ -322,6 +329,27 @@ public class EditSettingsGUI extends CommonGUI glow = this.settings.getUserGuiMode().equals(Settings.GuiMode.GAMEMODE_LIST); break; } + case GAMEMODE_GUI: + { + description = new ArrayList<>(2); + description.add(this.user.getTranslation("challenges.gui.descriptions.admin.gui-mode")); + description.add(this.user.getTranslation("challenges.gui.descriptions.current-value", + "[value]", + this.settings.isUseCommonGUI() ? + this.user.getTranslation("challenges.gui.descriptions.enabled") : + this.user.getTranslation("challenges.gui.descriptions.disabled"))); + name = this.user.getTranslation("challenges.gui.buttons.admin.gui-mode"); + icon = new ItemStack(Material.BLACK_STAINED_GLASS_PANE); + clickHandler = (panel, user1, clickType, i) -> { + this.settings.setUseCommonGUI(!this.settings.isUseCommonGUI()); + // We cannot use single item changing as this option enabling/disabling will change other + // option visibility. + this.build(); + return true; + }; + glow = this.settings.isUseCommonGUI(); + break; + } case HISTORY: { description = new ArrayList<>(2); @@ -446,8 +474,9 @@ public class EditSettingsGUI extends CommonGUI LEVEL_LORE, CHALLENGE_LORE, FREE_AT_TOP, - GAMEMODE_GUI, - HISTORY, + GAMEMODE_GUI_VIEW_MODE, + GAMEMODE_GUI, + HISTORY, PURGE_HISTORY, STORE_MODE, GLOW_COMPLETED, diff --git a/src/main/resources/locales/en-US.yml b/src/main/resources/locales/en-US.yml index 1743920..55c2b27 100755 --- a/src/main/resources/locales/en-US.yml +++ b/src/main/resources/locales/en-US.yml @@ -138,6 +138,7 @@ challenges: level-lore: 'Level Description' challenge-lore: 'Challenge Description' gui-view-mode: 'Display All GameModes' + gui-mode: 'Single Challenges GUI' history-store: 'Challenges History' history-lifespan: 'History LifeSpan' island-store: 'Store per Island' @@ -230,6 +231,7 @@ challenges: history-lifespan: 'Allows to modify how many days history data will be saved.|0 means forever.' island-store: 'Allows to enable/disable challenges data string per island. This means that challenges will be the same on whole team, if this is enabled.|Will NOT convert data on click. PROGRESS WILL BE LOST.' default-locked-icon: 'Allows to change default locked level icon.|This option can be overwritten by each level.' + gui-mode: 'Allows to enable/disable single challenges GUI.|&2Requires server restart.' current-value: '|&6Current value: [value].' enabled: 'Active' disabled: 'Disabled'