Package dev.aurelium.slate.builder
Class ItemBuilder
java.lang.Object
dev.aurelium.slate.builder.ItemBuilder
Class used to define functionality for an item in a menu.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()static ItemBuilderbuilder()Create a new ItemBuilder instanceinitialize(MenuListener listener) Defines a consumer to run when the item is initialized in the menu.modify(ItemModifier modifier) Modifies the item before it is displayed to the player.onClick(ClickTrigger action, ItemClicker clicker) Defines a consumer to run when the item is clicked by the player using a specific button.onClick(ItemClicker clicker) Defines a consumer to run when the item is clicked by the player using any button.replace(String from, ItemReplacer replacer) Replaces a specific placeholder in the item's display name or lore.replaceAny(ItemReplacer replacer) Replaces any placeholder in the item's display name or lore.
-
Constructor Details
-
ItemBuilder
public ItemBuilder()
-
-
Method Details
-
builder
Create a new ItemBuilder instance- Returns:
- the item builder
-
replace
Replaces a specific placeholder in the item's display name or lore.- Parameters:
from- the name of the placeholder without the curly bracesreplacer- theItemReplacerfunction- Returns:
- the item builder
-
replaceAny
Replaces any placeholder in the item's display name or lore. The replacer function is run for every placeholder that is found in the item's display name or lore. The name of the placeholder being checked can be accessed usingPlaceholderInfo.placeholder().- Parameters:
replacer- theItemReplacerfunction- Returns:
- the item builder
-
onClick
Defines a consumer to run when the item is clicked by the player using any button.- Parameters:
clicker- theItemClickerconsumer, which takes anItemInfoparameter- Returns:
- the item builder
-
onClick
Defines a consumer to run when the item is clicked by the player using a specific button.- Parameters:
action- the specificClickTriggerbutton to run the consumer forclicker- theItemClickerconsumer, which takes anItemInfoparameter- Returns:
- the item builder
-
modify
Modifies the item before it is displayed to the player.- Parameters:
modifier- theItemModifierfunction- Returns:
- the item builder
-
initialize
Defines a consumer to run when the item is initialized in the menu. This does not affect the item's display, usemodify(ItemModifier)for that.- Parameters:
listener- theMenuListenerconsumer, which takes anItemInfoparameter- Returns:
- the item builder
-
build
-