diff --git a/Core/src/main/java/com/songoda/core/SongodaCore.java b/Core/src/main/java/com/songoda/core/SongodaCore.java index ffdd7678..ab4f3b4d 100644 --- a/Core/src/main/java/com/songoda/core/SongodaCore.java +++ b/Core/src/main/java/com/songoda/core/SongodaCore.java @@ -53,7 +53,7 @@ public class SongodaCore { /** * This has been added as of Rev 6 */ - private final static String coreVersion = "2.4.24"; + private final static String coreVersion = "2.4.25"; /** * This is specific to the website api @@ -162,8 +162,7 @@ public class SongodaCore { private void init() { shadingListener = new ShadedEventListener(); commandManager.registerCommandDynamically(new SongodaCoreCommand()) - .addSubCommand(new SongodaCoreDiagCommand()) - .addSubCommand(new SongodaCoreShowGuiKeysCommand()); + .addSubCommand(new SongodaCoreDiagCommand()); Bukkit.getPluginManager().registerEvents(loginListener, piggybackedPlugin); Bukkit.getPluginManager().registerEvents(shadingListener, piggybackedPlugin); // we aggressively want to own this command diff --git a/Core/src/main/java/com/songoda/core/gui/CustomizableGui.java b/Core/src/main/java/com/songoda/core/gui/CustomizableGui.java index fe95be90..da243f03 100644 --- a/Core/src/main/java/com/songoda/core/gui/CustomizableGui.java +++ b/Core/src/main/java/com/songoda/core/gui/CustomizableGui.java @@ -25,6 +25,7 @@ import java.util.Map; public class CustomizableGui extends Gui { private static boolean showGuiKeys = false; + private int activationCount = 0; private static final Map loadedGuis = new HashMap<>(); private final CustomContent customContent; @@ -59,6 +60,7 @@ public class CustomizableGui extends Gui { config.saveChanges(); } + if (!config.isConfigurationSection("disabled")) { config.setDefault("disabled", Arrays.asList("example3", "example4", "example5"), "All keys on this list will be disabled. You can add any items key here", @@ -98,6 +100,15 @@ public class CustomizableGui extends Gui { } else { customContent = loadedGuis.get(guiKey); } + setPrivateDefaultAction(event -> { + if (event.clickType == ClickType.SHIFT_RIGHT) + activationCount ++; + if (activationCount >= 8 && event.player.hasPermission("songoda.admin")) { + showGuiKeys = !showGuiKeys; + activationCount = 0; + event.player.sendMessage("Gui keys " + (showGuiKeys ? "enabled" : "disabled") + "."); + } + }); if (customContent.isButtonCustomized("__DEFAULT__")) blankItem = GuiUtils.getBorderItem(customContent.getCustomizedButton("__DEFAULT__").item); @@ -511,11 +522,6 @@ public class CustomizableGui extends Gui { return newLore; } - public static boolean toggleShowGuiKeys() { - showGuiKeys = !showGuiKeys; - return showGuiKeys; - } - private class CustomButton { private final String key; diff --git a/Core/src/main/java/com/songoda/core/gui/Gui.java b/Core/src/main/java/com/songoda/core/gui/Gui.java index b9a9e12a..1b72a824 100644 --- a/Core/src/main/java/com/songoda/core/gui/Gui.java +++ b/Core/src/main/java/com/songoda/core/gui/Gui.java @@ -59,6 +59,7 @@ public class Gui { protected GuiManager guiManager; protected boolean open = false; protected Clickable defaultClicker = null; + protected Clickable privateDefaultClicker = null; protected Openable opener = null; protected Closable closer = null; protected Droppable dropper = null; @@ -279,6 +280,12 @@ public class Gui { return this; } + @NotNull + protected Gui setPrivateDefaultAction(@Nullable Clickable action) { + privateDefaultClicker = action; + return this; + } + @NotNull public Gui setDefaultItem(@Nullable ItemStack item) { blankItem = item; @@ -624,6 +631,12 @@ public class Gui { return this; } + public void reset() { + if (inventory != null) + inventory.clear(); + setActionForRange(0, 53, null); + } + @NotNull public Gui setNextPage(int cell, @NotNull ItemStack item) { nextPageIndex = cell; @@ -812,6 +825,10 @@ public class Gui { // this is a default action, not a triggered action defaultClicker.onClick(new GuiClickEvent(manager, this, player, event, cell, true)); } + if (privateDefaultClicker != null) { + // this is a private default action, not a triggered action + privateDefaultClicker.onClick(new GuiClickEvent(manager, this, player, event, cell, true)); + } return false; } return true;