mirror of
https://github.com/songoda/SongodaCore.git
synced 2024-11-24 02:56:17 +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 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;
|
||||||
|
Loading…
Reference in New Issue
Block a user