Class MapMenu
java.lang.Object
studio.magemonkey.codex.mccore.gui.MapMenu
Represents one menu of navigation for a map. Menus can
navigate between each other or be independent.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectRetrieves stored data for the player by keyfinal MapMenuRetrieves the parent menu for this menu.static MapScenegetScene(org.bukkit.entity.Player player) Retrieves the scene manager for the playerstatic IntegergetSelection(org.bukkit.entity.Player player) Gets the current selection of the playervoidonBack(org.bukkit.entity.Player player) Called when the back key is pressed.voidonDown(org.bukkit.entity.Player player) Called when the down key is pressed.voidonExit(org.bukkit.entity.Player player) Similar to onBack, this is provided in case you need to clean up values.voidonLeft(org.bukkit.entity.Player player) Called when the left key is pressed.voidonRight(org.bukkit.entity.Player player) Called when the right key is pressed.voidonSelect(org.bukkit.entity.Player player) Called when the select key is pressed.voidonUp(org.bukkit.entity.Player player) Called when the up key is pressed.abstract voidThe method used to render the map to the buffer.static voidSets data for the player that persists between menusfinal voidSets the parent of the menu which will be the menu that is returned to when the back button is hit.static voidsetSelection(org.bukkit.entity.Player player, int selection) Sets the current selection for the playervoidsetup(org.bukkit.entity.Player player) Provides any setup for a player that may need to be done when navigating to the menu such as setting up the scene or applying selection data.
-
Constructor Details
-
MapMenu
public MapMenu()
-
-
Method Details
-
getSelection
Gets the current selection of the player- Parameters:
player- player to get the selection of- Returns:
- the current selection of the player
-
setSelection
public static void setSelection(org.bukkit.entity.Player player, int selection) Sets the current selection for the player- Parameters:
player- player to set the selection forselection- selection to use
-
getScene
Retrieves the scene manager for the player- Parameters:
player- player to get the scene manager for- Returns:
- the scene manager for the player
-
getData
Retrieves stored data for the player by key- Parameters:
player- player to get the data forkey- key the data was stored under- Returns:
- the retrieved data
-
setData
Sets data for the player that persists between menus- Parameters:
player- player to set the data forkey- key to store the data underdata- data to store
-
getParent
Retrieves the parent menu for this menu. If a map was created using this menu as the top level, the parent will not be returned to despite hitting back. This is more for the global menu connecting everything together.- Returns:
- parent menu
-
setParent
Sets the parent of the menu which will be the menu that is returned to when the back button is hit.- Parameters:
menu- menu to return to when back is hit
-
render
The method used to render the map to the buffer. This will be called automatically when the player is looking at a map with this menu as the active menu.- Parameters:
buffer- buffer to draw to
-
setup
public void setup(org.bukkit.entity.Player player) Provides any setup for a player that may need to be done when navigating to the menu such as setting up the scene or applying selection data.- Parameters:
player- player to initialize
-
onUp
public void onUp(org.bukkit.entity.Player player) Called when the up key is pressed. This should be overridden when needed.- Parameters:
player- player that moved up
-
onDown
public void onDown(org.bukkit.entity.Player player) Called when the down key is pressed. This should be overridden when needed.- Parameters:
player- player that moved down
-
onLeft
public void onLeft(org.bukkit.entity.Player player) Called when the left key is pressed. This should be overridden when needed.- Parameters:
player- player that moved left
-
onRight
public void onRight(org.bukkit.entity.Player player) Called when the right key is pressed. This should be overridden when needed.- Parameters:
player- player that moved right
-
onSelect
public void onSelect(org.bukkit.entity.Player player) Called when the select key is pressed. This should be overridden when needed.- Parameters:
player- player that selected the current item
-
onBack
public void onBack(org.bukkit.entity.Player player) Called when the back key is pressed. This should be overridden when needed. Transitioning to the previous menu will be handled automatically for this control, but if you have other actions you want to take care of such as applying changes before exiting, apply them here.- Parameters:
player- player that hit the back button
-
onExit
public void onExit(org.bukkit.entity.Player player) Similar to onBack, this is provided in case you need to clean up values. This is when the player switches their item from the map, exiting the menu.- Parameters:
player- player that exited the menu
-