Package net.tnemc.menu.core.builder
Class IconBuilder
java.lang.Object
net.tnemc.menu.core.builder.IconBuilder
-
Field Summary
Modifier and TypeFieldDescriptionprivate final List<IconAction>
private Consumer<MenuClickHandler>
private String
private final net.tnemc.item.AbstractItemStack<?>
private Function<MenuPlayer,
net.tnemc.item.AbstractItemStack<?>> private int
private String
-
Constructor Summary
ConstructorDescriptionIconBuilder
(@NotNull net.tnemc.item.AbstractItemStack<?> item) Constructs anIconBuilder
with 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 aSlotPos
object.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 anIconBuilder
with the specified item.- Parameters:
item
- TheAbstractItemStack
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 theMenuPlayer
.- Returns:
- This
IconBuilder
instance for method chaining.
-
withSlot
Sets the slot for the icon.- Parameters:
slot
- The slot position for the icon.- Returns:
- This
IconBuilder
instance 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
IconBuilder
instance for method chaining.
-
withStateID
Sets the state ID for the StateIcon.- Parameters:
stateID
- The state ID for the StateIcon.- Returns:
- This
IconBuilder
instance for method chaining.
-
withDefaultState
Sets the default state for the StateIcon.- Parameters:
defaultState
- The default state for the StateIcon.- Returns:
- This
IconBuilder
instance for method chaining.
-
withStateHandler
Sets the state handler for the StateIcon.- Parameters:
stateHandler
- The state handler for the StateIcon.- Returns:
- This
IconBuilder
instance for method chaining.
-
withState
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
- Returns:
- The constructed
Icon
orStateIcon
instance.
-