Class ActiveMenu

java.lang.Object
dev.aurelium.slate.menu.ActiveMenu
Direct Known Subclasses:
EmptyActiveMenu

public class ActiveMenu extends Object
  • Constructor Details

  • Method Details

    • empty

      public static ActiveMenu empty(Slate slate, org.bukkit.entity.Player player)
    • getName

      public String getName()
    • setHidden

      public void setHidden(String itemName, boolean hidden)
      Hides or shows an item in the current menu, will not delete the item in configs. Will not take effect unless the menu is reloaded.
      Parameters:
      itemName - The name of the item to hide
    • getCurrentPage

      public int getCurrentPage()
      Gets the current page of the menu, 0 is the first page
      Returns:
      The current page number, 0 if there is no pagination set up
    • getTotalPages

      public int getTotalPages()
      Gets the total number of pages in the menu
      Returns:
      The total number of pages, 1 if there is no pagination set up
    • property

      public <T> T property(String name)
      Gets a property from a name cast to a type.
      Type Parameters:
      T - the type of the value
      Parameters:
      name - the property name
      Returns:
      the property value, or null if it isn't defined
    • property

      public <T> T property(String name, T def)
      Gets a property from a name cast to a type or a default value.
      Type Parameters:
      T - the type of the value
      Parameters:
      name - the property name
      def - the default fallback value
      Returns:
      the property value, or def
    • getProperty

      public Object getProperty(String name)
      Gets a property from the menu's properties with the given name.
      Parameters:
      name - the name of the property
      Returns:
      the property value as an Object
    • getProperty

      public Object getProperty(String name, Object def)
      Gets a property from the menu's properties with the given name, or returns the default value if the property does not exist.
      Parameters:
      name - the name of the property
      def - the default value to return if the property does not exist
      Returns:
      the property value as an Object, or the default value if the property does not exist
    • getProperties

      public Map<String,Object> getProperties()
      Gets all properties from the menu's properties.
      Returns:
      a Map of all properties
    • setProperty

      public void setProperty(String name, Object value)
      Sets a property in the menu's properties with the given name and value.
      Parameters:
      name - the name of the property
      value - the value of the property
    • defaultProperty

      public void defaultProperty(String name, Object value)
      Sets a property only if a property with the given name has not been set.
      Parameters:
      name - the name of the property
      value - the value of the property
    • reload

      public void reload()
      Reloads the menu for the player as if it was reopened.
    • setCooldown

      public void setCooldown(String itemName, int cooldown)
      Sets the cooldown of an item in the current menu. Items on cooldown will not be able to be clicked.
      Parameters:
      itemName - the name of the item to set the cooldown for
      cooldown - the cooldown in ticks
    • getOption

      @Nullable public @Nullable Object getOption(String key)
      Gets the value of an option from the menu's configurable options.
      Parameters:
      key - the key of the option
      Returns:
      the value of the option as an Object
    • getOption

      @Nullable public <T> T getOption(Class<T> clazz, String key)
      Gets the value of an option from the menu's configurable options cast to a type.
      Type Parameters:
      T - the type of the option
      Parameters:
      clazz - the class of the option to cast to
      key - the key of the option
      Returns:
      the value of the option as the specified type, or null if the option does not exist
    • getOption

      public Object getOption(String key, Object def)
      Gets the value of an option from the menu's configurable options, or returns the default value if the option does not exist.
      Parameters:
      key - the key of the option
      def - the default value to return if the option does not exist
      Returns:
      the value of the option as an Object, or the default value if the option does not exist
    • getOption

      public <T> T getOption(Class<T> clazz, String key, T def)
      Gets the value of an option from the menu's configurable options cast to a type, or returns the default value if the option does not exist.
      Type Parameters:
      T - the type of the option
      Parameters:
      clazz - the class of the option to cast to
      key - the key of the option
      def - the default value to return if the option does not exist
      Returns:
      the value of the option as the specified type, or the default value if the option does not exist
    • getItemOption

      @Nullable public @Nullable Object getItemOption(String itemName, String key)
    • getItemOption

      public Object getItemOption(String itemName, String key, Object def)
    • getComponents

      public Map<String,MenuComponent> getComponents()
    • getFormats

      public Map<String,String> getFormats()
    • getFormat

      @NotNull public @NotNull String getFormat(String key)
      Gets a format from the menu's formats, returns the key if the format does not exist
      Parameters:
      key - The key of the format
      Returns:
      The format, or the key if the format does not exist
    • setPositionProvider

      public <T> void setPositionProvider(String templateName, T context, PositionProvider provider)
    • getContextGroups

      public Map<String,ContextGroup> getContextGroups(String templateName)