Class MapMenu

java.lang.Object
studio.magemonkey.codex.mccore.gui.MapMenu

public abstract class MapMenu extends Object
Represents one menu of navigation for a map. Menus can navigate between each other or be independent.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static Object
    getData(org.bukkit.entity.Player player, String key)
    Retrieves stored data for the player by key
    final MapMenu
    Retrieves the parent menu for this menu.
    static MapScene
    getScene(org.bukkit.entity.Player player)
    Retrieves the scene manager for the player
    static Integer
    getSelection(org.bukkit.entity.Player player)
    Gets the current selection of the player
    void
    onBack(org.bukkit.entity.Player player)
    Called when the back key is pressed.
    void
    onDown(org.bukkit.entity.Player player)
    Called when the down key is pressed.
    void
    onExit(org.bukkit.entity.Player player)
    Similar to onBack, this is provided in case you need to clean up values.
    void
    onLeft(org.bukkit.entity.Player player)
    Called when the left key is pressed.
    void
    onRight(org.bukkit.entity.Player player)
    Called when the right key is pressed.
    void
    onSelect(org.bukkit.entity.Player player)
    Called when the select key is pressed.
    void
    onUp(org.bukkit.entity.Player player)
    Called when the up key is pressed.
    abstract void
    render(MapBuffer buffer, org.bukkit.entity.Player player)
    The method used to render the map to the buffer.
    static void
    setData(org.bukkit.entity.Player player, String key, Object data)
    Sets data for the player that persists between menus
    final void
    Sets the parent of the menu which will be the menu that is returned to when the back button is hit.
    static void
    setSelection(org.bukkit.entity.Player player, int selection)
    Sets the current selection for the player
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MapMenu

      public MapMenu()
  • Method Details

    • getSelection

      public static Integer getSelection(org.bukkit.entity.Player player)
      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 for
      selection - selection to use
    • getScene

      public static MapScene getScene(org.bukkit.entity.Player player)
      Retrieves the scene manager for the player
      Parameters:
      player - player to get the scene manager for
      Returns:
      the scene manager for the player
    • getData

      public static Object getData(org.bukkit.entity.Player player, String key)
      Retrieves stored data for the player by key
      Parameters:
      player - player to get the data for
      key - key the data was stored under
      Returns:
      the retrieved data
    • setData

      public static void setData(org.bukkit.entity.Player player, String key, Object data)
      Sets data for the player that persists between menus
      Parameters:
      player - player to set the data for
      key - key to store the data under
      data - data to store
    • getParent

      public final MapMenu 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

      public final void setParent(MapMenu menu)
      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

      public abstract void render(MapBuffer buffer, org.bukkit.entity.Player player)
      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