Class StateIcon

java.lang.Object
net.tnemc.menu.core.icon.Icon
net.tnemc.menu.core.icon.impl.StateIcon
All Implemented Interfaces:
ConstraintHolder

public class StateIcon extends Icon
The StateIcon class represents an icon with a dynamic state that is determined by a state handler.
Since:
1.5.0.0
Author:
creatorfromhell
See Also:
  • Field Details

    • states

      private final Map<String,net.tnemc.item.AbstractItemStack<?>> states
    • stateID

      private final String stateID
    • defaultState

      private final String defaultState
    • stateHandler

      protected final Function<String,String> stateHandler
      The function responsible for determining the state of the icon based on its current state.
  • Constructor Details

    • StateIcon

      public StateIcon(@NotNull @NotNull net.tnemc.item.AbstractItemStack<?> item, @Nullable @Nullable Function<MenuPlayer,net.tnemc.item.AbstractItemStack<?>> itemProvider, String stateID, String defaultState, @NotNull @NotNull Function<String,String> stateHandler)
  • Method Details

    • getStates

      public Map<String,net.tnemc.item.AbstractItemStack<?>> getStates()
    • addState

      public void addState(String stateID, net.tnemc.item.AbstractItemStack<?> item)
    • onClick

      public boolean onClick(MenuClickHandler handler)
      Overrides:
      onClick in class Icon
    • getItem

      public net.tnemc.item.AbstractItemStack<?> getItem(@Nullable @Nullable MenuPlayer player)
      Retrieves the current item of the icon by applying the state handler.
      Overrides:
      getItem in class Icon
      Parameters:
      player - The player that is viewing the menu.
      Returns:
      The item representing the current state of the icon.