Class TradeInventoryExample
java.lang.Object
me.eddie.inventoryguiapi.examples.TradeInventoryExample
- All Implemented Interfaces:
GUIContentsProvider,GUIActionListener
An example of using the API to create a GUI for
two players to trade items with each other.
-
Nested Class Summary
Nested classes/interfaces inherited from interface me.eddie.inventoryguiapi.gui.contents.GUIContentsProvider
GUIContentsProvider.GUIContentsResponse -
Field Summary
Fields inherited from interface me.eddie.inventoryguiapi.gui.contents.GUIContentsProvider
MAX_JAVA_TITLE_LENGTH -
Constructor Summary
ConstructorsConstructorDescriptionTradeInventoryExample(org.bukkit.entity.Player leftSide, org.bukkit.entity.Player rightSide) -
Method Summary
Modifier and TypeMethodDescriptionvoidgenContents(org.bukkit.entity.Player viewer, int page, GUISession session, Callback<GUIContentsProvider.GUIContentsResponse> callback) Calculate the GUIElements to display on this page and if another exists.voidgenTitle(org.bukkit.entity.Player viewer, int page, GUISession session, Callback<String> callback) Calculate the title to display for a given page.protected voidvoidMethod is called when an event happens to this GUI.voidprotected voidtradeItems(GUISession session)
-
Constructor Details
-
TradeInventoryExample
public TradeInventoryExample(org.bukkit.entity.Player leftSide, org.bukkit.entity.Player rightSide)
-
-
Method Details
-
startTrade
public void startTrade() -
initInputSlots
protected void initInputSlots() -
onEvent
Description copied from interface:GUIActionListenerMethod is called when an event happens to this GUI. Cancelling a GUIEvent will prevent further handling of it by the API, but will not cancel the Bukkit event that caused it. To cancel the Bukkit event causing this GUIEvent, use the GUIEvent to find the Bukkit event that caused it and cancel this.- Specified by:
onEventin interfaceGUIActionListener- Parameters:
event- The event to be handled.
-
tradeItems
-
genContents
public void genContents(org.bukkit.entity.Player viewer, int page, GUISession session, Callback<GUIContentsProvider.GUIContentsResponse> callback) Description copied from interface:GUIContentsProviderCalculate the GUIElements to display on this page and if another exists. Once calculated the result (a GUIContentsResponse) should be passed to the provided callback. If the callback isn't called then the GUI will not work properly.- Specified by:
genContentsin interfaceGUIContentsProvider- Parameters:
viewer- The viewer of this inventory. In the case of a GUI with multiple viewers (SharedInventoryGUI) this will be whatever viewer caused this method to be calledpage- The page to retrieve the contents for. Page 1 is the first page.session- The GUISession being viewedcallback- The callback to pass the response to. If the callback isn't called then the GUI will not work properly. Use theCallback.call(Object)method of the callback.
-
genTitle
public void genTitle(org.bukkit.entity.Player viewer, int page, GUISession session, Callback<String> callback) Description copied from interface:GUIContentsProviderCalculate the title to display for a given page. Once calculated the result (a String) should be passed to the provided callback. If the callback isn't called then the GUI will not work properly.- Specified by:
genTitlein interfaceGUIContentsProvider- Parameters:
viewer- The viewer of this inventory. In the case of a GUI with multiple viewers (SharedInventoryGUI) this will be whatever viewer caused this method to be calledpage- The page to retrieve the contents for. Page 1 is the first page.session- The GUISession being viewedcallback- The callback to pass the response to. If the callback isn't called then the GUI will not work properly. Use theCallback.call(Object)method of the callback.
-