Package com.coderyo.coderyogui.api
Class GUIItemBuilder
java.lang.Object
com.coderyo.coderyogui.api.GUIItemBuilder
A builder class for creating
GUIItem instances with customizable properties
such as material, name, lore, takeability, and actions.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionSets the list of actions for the GUI item.Adds a custom action to the GUI item.Adds an action to close the player's GUI.addCommandAction(String command, boolean asConsole) Adds a command action to the GUI item.Adds a single line to the GUI item's lore.addMessageAction(String message) Adds a message action to send a chat message to the player.addSoundAction(String sound, float volume, float pitch) Adds a sound action to play a sound for the player.build()Builds and returns the configured GUIItem.Sets the lore (description) of the GUI item.Sets the material of the GUI item.Sets the display name of the GUI item.takeable(boolean takeable) Sets whether the GUI item can be taken by players.
-
Constructor Details
-
GUIItemBuilder
public GUIItemBuilder()
-
-
Method Details
-
material
Sets the material of the GUI item.- Parameters:
material- The material name (e.g., "DIAMOND"). Defaults to "AIR" if null.- Returns:
- This builder instance for method chaining.
-
name
Sets the display name of the GUI item.- Parameters:
name- The display name, or null for no custom name.- Returns:
- This builder instance for method chaining.
-
lore
Sets the lore (description) of the GUI item.- Parameters:
lore- The list of lore lines, or null for an empty list.- Returns:
- This builder instance for method chaining.
-
addLore
Adds a single line to the GUI item's lore.- Parameters:
line- The lore line to add.- Returns:
- This builder instance for method chaining.
-
takeable
Sets whether the GUI item can be taken by players.- Parameters:
takeable- true if the item can be taken, false otherwise. Defaults to false.- Returns:
- This builder instance for method chaining.
-
addAction
Adds a custom action to the GUI item.- Parameters:
action- The action to add, or null (ignored).- Returns:
- This builder instance for method chaining.
-
addCommandAction
Adds a command action to the GUI item.- Parameters:
command- The command to execute (e.g., "give %player% diamond 1").asConsole- true to execute as console, false to execute as player.- Returns:
- This builder instance for method chaining.
-
addMessageAction
Adds a message action to send a chat message to the player.- Parameters:
message- The message to send.- Returns:
- This builder instance for method chaining.
-
addSoundAction
Adds a sound action to play a sound for the player.- Parameters:
sound- The sound name (e.g., "ENTITY_EXPERIENCE_ORB_PICKUP").volume- The sound volume (default 1.0).pitch- The sound pitch (default 1.0).- Returns:
- This builder instance for method chaining.
-
addCloseAction
Adds an action to close the player's GUI.- Returns:
- This builder instance for method chaining.
-
actions
Sets the list of actions for the GUI item.- Parameters:
actions- The list of actions, or null for an empty list.- Returns:
- This builder instance for method chaining.
-
build
Builds and returns the configured GUIItem.- Returns:
- The constructed GUIItem instance.
-