Package net.citizensnpcs.api.gui
Class InventoryMenu
java.lang.Object
net.citizensnpcs.api.gui.InventoryMenu
A container class for Inventory GUIs. Expects
onInventoryClick(InventoryClickEvent) and
onInventoryClose(InventoryCloseEvent) to be called by the user (or registered with the event listener
system). Optionally, run() can also be called every tick.
Inventory GUIs are defined as a stack of InventoryMenuPages, each of which represents a distinct inventory
that is transitioned between using either code or user clicks using the InventoryMenuTransition class. Each
InventoryMenuPage should define a Menu annotation at the class level.
Each page has a number of InventoryMenuSlots which define attributes such as default slot item,
interactibility, etc.
You can define sets of slots and transitions using InventoryMenuPattern.
For each concrete class of slot/transition/pattern there is a corresponding annotation that is defined.
InventoryMenuPages can either annotate specific instances of these concrete classes which will be injected at
runtime or simply place them at the method/class level.
Instances of global/contextual variables can be injected dynamically via InjectContext which sources
variables from the MenuContext.-
Constructor Summary
ConstructorsConstructorDescriptionInventoryMenu(net.citizensnpcs.api.gui.InventoryMenu.InventoryMenuInfo info, InventoryMenuPage instance) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the GUI and all associated viewer inventories.voidclose(HumanEntity entity) Closes the GUI for just a specific Player.static InventoryMenucreate(Class<? extends InventoryMenuPage> clazz) Create an inventory menu instance starting at the given page.static InventoryMenucreate(InventoryMenuPage instance) Create an inventory menu instance starting at the given page.static InventoryMenucreateSelfRegistered(Class<? extends InventoryMenuPage> clazz) Creates an inventory menu instance starting at the given page that registers events and deregisters events when the menu is closed.static InventoryMenucreateSelfRegistered(InventoryMenuPage instance) Creates an inventory menu instance starting at the given page that registers events and deregisters events when the menu is closed.static InventoryMenucreateWithContext(Class<? extends InventoryMenuPage> clazz, Map<String, Object> context) Create an inventory menu instance starting at the given page and with the initial context.voidvoidvoidvoidpresent(HumanEntity player) Display the menu to the given player.voidrun()voidtransition(Class<? extends InventoryMenuPage> clazz) Transition to another page.voidtransition(Class<? extends InventoryMenuPage> clazz, Map<String, Object> context) Transition to another page with context.voidtransition(InventoryMenuPage instance) Transition to another page.voidtransition(InventoryMenuPage instance, Map<String, Object> context) Transition to another page with context.void
-
Constructor Details
-
InventoryMenu
public InventoryMenu(net.citizensnpcs.api.gui.InventoryMenu.InventoryMenuInfo info, InventoryMenuPage instance)
-
-
Method Details
-
close
public void close()Closes the GUI and all associated viewer inventories. -
close
Closes the GUI for just a specific Player. -
onInventoryClick
-
onInventoryClose
-
onInventoryDrag
-
present
Display the menu to the given player. Multiple players can be shown the same menu, but transitions will affect all players and the inventory is shared. -
run
public void run() -
transition
Transition to another page. Adds the previous page to a stack which will be returned to when the current page is closed. -
transition
Transition to another page with context. Adds the previous page to a stack which will be returned to when the current page is closed. -
transition
Transition to another page. Adds the previous page to a stack which will be returned to when the current page is closed. -
transition
Transition to another page with context. Adds the previous page to a stack which will be returned to when the current page is closed. -
transitionBack
public void transitionBack() -
create
Create an inventory menu instance starting at the given page. -
create
Create an inventory menu instance starting at the given page. -
createSelfRegistered
Creates an inventory menu instance starting at the given page that registers events and deregisters events when the menu is closed. -
createSelfRegistered
Creates an inventory menu instance starting at the given page that registers events and deregisters events when the menu is closed. -
createWithContext
public static InventoryMenu createWithContext(Class<? extends InventoryMenuPage> clazz, Map<String, Object> context) Create an inventory menu instance starting at the given page and with the initial context.
-