Class IconBuilder

java.lang.Object
net.tnemc.menu.core.builder.IconBuilder

public class IconBuilder extends Object
Builder class for creating instances of the Icon and StateIcon classes.
Since:
1.5.0.0
Author:
creatorfromhell
See Also:
  • Field Details

  • Constructor Details

    • IconBuilder

      public IconBuilder(@NotNull @NotNull net.tnemc.item.AbstractItemStack<?> item)
      Constructs an IconBuilder with the specified item.
      Parameters:
      item - The AbstractItemStack to be used in the icon.
  • Method Details

    • withItemProvider

      public IconBuilder withItemProvider(@Nullable @Nullable Function<MenuPlayer,net.tnemc.item.AbstractItemStack<?>> itemProvider)
      Sets the item provider function for the icon.
      Parameters:
      itemProvider - The function providing the item for the icon based on the MenuPlayer.
      Returns:
      This IconBuilder instance for method chaining.
    • withSlot

      public IconBuilder withSlot(int slot)
      Sets the slot for the icon.
      Parameters:
      slot - The slot position for the icon.
      Returns:
      This IconBuilder instance for method chaining.
    • withSlot

      public IconBuilder withSlot(SlotPos slotPos)
      Sets the slot for the icon using a SlotPos object.
      Parameters:
      slotPos - The SlotPos representing the slot position for the icon.
      Returns:
      This IconBuilder instance for method chaining.
    • withClick

      public IconBuilder withClick(Consumer<MenuClickHandler> click)
      Sets the click handler for the icon.
      Parameters:
      click - The click handler to be executed when the icon is clicked.
      Returns:
      This IconBuilder instance for method chaining.
    • withConstraint

      public IconBuilder withConstraint(Constraint<?> key, String value)
      Adds a constraint to the icon.
      Parameters:
      key - The key of the constraint.
      value - The value of the constraint.
      Returns:
      This IconBuilder instance for method chaining.
    • withActions

      public IconBuilder withActions(IconAction... actions)
      Adds actions to the list of actions for the icon.
      Parameters:
      actions - The actions to be added to the icon.
      Returns:
      This IconBuilder instance for method chaining.
    • withStateID

      public IconBuilder withStateID(String stateID)
      Sets the state ID for the StateIcon.
      Parameters:
      stateID - The state ID for the StateIcon.
      Returns:
      This IconBuilder instance for method chaining.
    • withDefaultState

      public IconBuilder withDefaultState(String defaultState)
      Sets the default state for the StateIcon.
      Parameters:
      defaultState - The default state for the StateIcon.
      Returns:
      This IconBuilder instance for method chaining.
    • withStateHandler

      public IconBuilder withStateHandler(Function<String,String> stateHandler)
      Sets the state handler for the StateIcon.
      Parameters:
      stateHandler - The state handler for the StateIcon.
      Returns:
      This IconBuilder instance for method chaining.
    • withState

      public IconBuilder withState(String stateID, net.tnemc.item.AbstractItemStack<?> item)
      Adds a state to the StateIcon.
      Parameters:
      stateID - The state ID.
      item - The item associated with the state.
      Returns:
      This IconBuilder instance for method chaining.
    • build

      public Icon build()
      Builds and returns the Icon or StateIcon instance based on the provided configuration.
      Returns:
      The constructed Icon or StateIcon instance.