add default action for gui

This commit is contained in:
jascotty2 2019-09-02 13:54:23 -05:00
parent b18dd1ccaf
commit 073c79dc50

View File

@ -52,6 +52,7 @@ public class Gui {
protected static ItemStack AIR = new ItemStack(Material.AIR); protected static ItemStack AIR = new ItemStack(Material.AIR);
protected boolean open = false; protected boolean open = false;
protected Clickable defaultClicker = null;
protected Openable opener = null; protected Openable opener = null;
protected Closable closer = null; protected Closable closer = null;
protected Droppable dropper = null; protected Droppable dropper = null;
@ -211,6 +212,11 @@ public class Gui {
return this; return this;
} }
public Gui setDefaultAction(Clickable action) {
defaultClicker = action;
return this;
}
public Gui setDefaultItem(ItemStack item) { public Gui setDefaultItem(ItemStack item) {
blankItem = item; blankItem = item;
return this; return this;
@ -602,6 +608,10 @@ public class Gui {
button.onClick(new GuiClickEvent(manager, this, player, event, cell, true)); button.onClick(new GuiClickEvent(manager, this, player, event, cell, true));
} else { } else {
// no event for this button // no event for this button
if(defaultClicker != null) {
// this is a default action, not a triggered action
defaultClicker.onClick(new GuiClickEvent(manager, this, player, event, cell, true));
}
return false; return false;
} }
return true; return true;