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 boolean open = false;
protected Clickable defaultClicker = null;
protected Openable opener = null;
protected Closable closer = null;
protected Droppable dropper = null;
@ -211,6 +212,11 @@ public class Gui {
return this;
}
public Gui setDefaultAction(Clickable action) {
defaultClicker = action;
return this;
}
public Gui setDefaultItem(ItemStack item) {
blankItem = item;
return this;
@ -602,6 +608,10 @@ public class Gui {
button.onClick(new GuiClickEvent(manager, this, player, event, cell, true));
} else {
// 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 true;