Package net.tnemc.menu.core.builder
Class IconBuilder
java.lang.Object
net.tnemc.menu.core.builder.IconBuilder
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final List<IconAction>private Consumer<MenuClickHandler>private Stringprivate final net.tnemc.item.AbstractItemStack<?>private Function<MenuPlayer,net.tnemc.item.AbstractItemStack<?>> private intprivate String -
Constructor Summary
ConstructorsConstructorDescriptionIconBuilder(@NotNull net.tnemc.item.AbstractItemStack<?> item) Constructs anIconBuilderwith the specified item. -
Method Summary
Modifier and TypeMethodDescriptionbuild()withActions(IconAction... actions) Adds actions to the list of actions for the icon.withClick(Consumer<MenuClickHandler> click) Sets the click handler for the icon.withConstraint(Constraint<?> key, String value) Adds a constraint to the icon.withDefaultState(String defaultState) Sets the default state for the StateIcon.withItemProvider(@Nullable Function<MenuPlayer, net.tnemc.item.AbstractItemStack<?>> itemProvider) Sets the item provider function for the icon.withSlot(int slot) Sets the slot for the icon.Sets the slot for the icon using aSlotPosobject.Adds a state to the StateIcon.withStateHandler(Function<String, String> stateHandler) Sets the state handler for the StateIcon.withStateID(String stateID) Sets the state ID for the StateIcon.
-
Field Details
-
item
private final net.tnemc.item.AbstractItemStack<?> item -
itemProvider
-
slot
private int slot -
click
-
actions
-
constraints
-
states
-
stateID
-
defaultState
-
stateHandler
-
-
Constructor Details
-
IconBuilder
public IconBuilder(@NotNull @NotNull net.tnemc.item.AbstractItemStack<?> item) Constructs anIconBuilderwith the specified item.- Parameters:
item- TheAbstractItemStackto 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 theMenuPlayer.- Returns:
- This
IconBuilderinstance for method chaining.
-
withSlot
Sets the slot for the icon.- Parameters:
slot- The slot position for the icon.- Returns:
- This
IconBuilderinstance for method chaining.
-
withClick
Sets the click handler for the icon.- Parameters:
click- The click handler to be executed when the icon is clicked.- Returns:
- This
IconBuilderinstance for method chaining.
-
withStateID
Sets the state ID for the StateIcon.- Parameters:
stateID- The state ID for the StateIcon.- Returns:
- This
IconBuilderinstance for method chaining.
-
withDefaultState
Sets the default state for the StateIcon.- Parameters:
defaultState- The default state for the StateIcon.- Returns:
- This
IconBuilderinstance for method chaining.
-
withStateHandler
Sets the state handler for the StateIcon.- Parameters:
stateHandler- The state handler for the StateIcon.- Returns:
- This
IconBuilderinstance for method chaining.
-
withState
Adds a state to the StateIcon.- Parameters:
stateID- The state ID.item- The item associated with the state.- Returns:
- This
IconBuilderinstance for method chaining.
-
build
- Returns:
- The constructed
IconorStateIconinstance.
-