mirror of
https://github.com/songoda/SongodaCore.git
synced 2024-11-27 12:35:12 +01:00
Removed the command and replaced it with an activation sequence.
This commit is contained in:
parent
3935f920f9
commit
35f3d381dc
@ -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
|
||||
|
@ -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<String, CustomContent> 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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user