Package dev.aurelium.slate.menu
Class ActiveMenu
java.lang.Object
dev.aurelium.slate.menu.ActiveMenu
- Direct Known Subclasses:
EmptyActiveMenu
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddefaultProperty(String name, Object value) Sets a property only if a property with the given name has not been set.static ActiveMenugetContextGroups(String templateName) intGets the current page of the menu, 0 is the first page@NotNull StringGets a format from the menu's formats, returns the key if the format does not exist@Nullable ObjectgetItemOption(String itemName, String key) getItemOption(String itemName, String key, Object def) getName()<T> TGets the value of an option from the menu's configurable options cast to a type.<T> TGets 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.@Nullable ObjectGets the value of an option from the menu's configurable options.Gets the value of an option from the menu's configurable options, or returns the default value if the option does not exist.Gets all properties from the menu's properties.getProperty(String name) Gets a property from the menu's properties with the given name.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.intGets the total number of pages in the menu<T> TGets a property from a name cast to a type.<T> TGets a property from a name cast to a type or a default value.voidreload()Reloads the menu for the player as if it was reopened.voidsetCooldown(String itemName, int cooldown) Sets the cooldown of an item in the current menu.voidHides or shows an item in the current menu, will not delete the item in configs.<T> voidsetPositionProvider(String templateName, T context, PositionProvider provider) voidsetProperty(String name, Object value) Sets a property in the menu's properties with the given name and value.
-
Constructor Details
-
Method Details
-
empty
-
getName
-
setHidden
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
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
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 namedef- the default fallback value- Returns:
- the property value, or def
-
getProperty
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
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 propertydef- 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
Gets all properties from the menu's properties.- Returns:
- a Map of all properties
-
setProperty
Sets a property in the menu's properties with the given name and value.- Parameters:
name- the name of the propertyvalue- the value of the property
-
defaultProperty
Sets a property only if a property with the given name has not been set.- Parameters:
name- the name of the propertyvalue- the value of the property
-
reload
public void reload()Reloads the menu for the player as if it was reopened. -
setCooldown
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 forcooldown- the cooldown in ticks
-
getOption
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
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 tokey- the key of the option- Returns:
- the value of the option as the specified type, or null if the option does not exist
-
getOption
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 optiondef- 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
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 tokey- the key of the optiondef- 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
-
getItemOption
-
getComponents
-
getFormats
-
getFormat
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
-
getContextGroups
-