Class GUIItemBuilder

java.lang.Object
com.coderyo.coderyogui.api.GUIItemBuilder

public class GUIItemBuilder extends Object
A builder class for creating GUIItem instances with customizable properties such as material, name, lore, takeability, and actions.
  • Constructor Details

    • GUIItemBuilder

      public GUIItemBuilder()
  • Method Details

    • material

      public GUIItemBuilder material(String 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

      public GUIItemBuilder name(String 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

      public GUIItemBuilder lore(List<String> 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

      public GUIItemBuilder addLore(String line)
      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

      public GUIItemBuilder takeable(boolean 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

      public GUIItemBuilder addAction(GUIAction action)
      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

      public GUIItemBuilder addCommandAction(String command, boolean asConsole)
      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

      public GUIItemBuilder addMessageAction(String message)
      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

      public GUIItemBuilder addSoundAction(String sound, float volume, float pitch)
      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

      public GUIItemBuilder addCloseAction()
      Adds an action to close the player's GUI.
      Returns:
      This builder instance for method chaining.
    • actions

      public GUIItemBuilder actions(List<GUIAction> 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

      public GUIItem build()
      Builds and returns the configured GUIItem.
      Returns:
      The constructed GUIItem instance.