mirror of
https://github.com/songoda/SongodaCore.git
synced 2024-11-23 18:45:34 +01:00
add default action for gui
This commit is contained in:
parent
b18dd1ccaf
commit
073c79dc50
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user