Class Structure

java.lang.Object
xyz.xenondevs.invui.gui.structure.Structure
All Implemented Interfaces:
Cloneable

public class Structure extends Object implements Cloneable
Provides an easy way to design Guis. Inspired by Bukkit's ShapedRecipe, Structures will let you design a Gui in a similar way.
  • Constructor Details

    • Structure

      public Structure(@NotNull @NotNull String @NotNull ... structureData)
      Sets the Structure of the Gui using the given structure data Strings. Each String is interpreted as a row of the Gui. All Strings must have the same length.
      Parameters:
      structureData - The structure data
    • Structure

      public Structure(int width, int height, @NotNull @NotNull String structureData)
      Sets the Structure of the Gui using the given structure data, width and height.
      Parameters:
      width - The width of the Gui
      height - The height of the Gui
      structureData - The structure data
  • Method Details

    • addGlobalIngredient

      public static void addGlobalIngredient(char key, @NotNull @NotNull org.bukkit.inventory.ItemStack itemStack)
      Adds a global ItemStack ingredient under the given key. Global ingredients will be used for all Structures which do not have an ingredient defined for that key.
      Parameters:
      key - The key of the ingredient
      itemStack - The ItemStack ingredient
    • addGlobalIngredient

      public static void addGlobalIngredient(char key, @NotNull @NotNull ItemProvider itemProvider)
      Adds a global ItemProvider ingredient under the given key. Global ingredients will be used for all Structures which do not have an ingredient defined for that key.
      Parameters:
      key - The key of the ingredient
      itemProvider - The ItemProvider ingredient
    • addGlobalIngredient

      public static void addGlobalIngredient(char key, @NotNull @NotNull Item item)
      Adds a global Item ingredient under the given key. Global ingredients will be used for all Structures which do not have an ingredient defined for that key.
      Parameters:
      key - The key of the ingredient
      item - The Item ingredient
    • addGlobalIngredient

      public static void addGlobalIngredient(char key, @NotNull @NotNull Supplier<? extends Item> itemSupplier)
      Adds a global Item Supplier ingredient under the given key. Global ingredients will be used for all Structures which do not have an ingredient defined for that key.
      Parameters:
      key - The key of the ingredient
      itemSupplier - The Item Supplier ingredient
    • addGlobalIngredient

      public static void addGlobalIngredient(char key, @NotNull @NotNull SlotElement element)
      Adds a global SlotElement ingredient under the given key. Global ingredients will be used for all Structures which do not have an ingredient defined for that key.
      Parameters:
      key - The key of the ingredient
      element - The SlotElement ingredient
    • addGlobalIngredient

      public static void addGlobalIngredient(char key, @NotNull @NotNull Marker marker)
      Adds a global Marker ingredient under the given key. Global ingredients will be used for all Structures which do not have an ingredient defined for that key.
      Parameters:
      key - The key of the ingredient
      marker - The Marker ingredient
    • addGlobalIngredientElementSupplier

      public static void addGlobalIngredientElementSupplier(char key, @NotNull @NotNull Supplier<? extends SlotElement> elementSupplier)
      Adds a global SlotElement Supplier ingredient under the given key. Global ingredients will be used for all Structures which do not have an ingredient defined for that key.
      Parameters:
      key - The key of the ingredient
      elementSupplier - The SlotElement Supplier ingredient
    • addIngredient

      @Contract("_, _ -> this") @NotNull public @NotNull Structure addIngredient(char key, @NotNull @NotNull org.bukkit.inventory.ItemStack itemStack)
      Adds an ItemStack ingredient under the given key.
      Parameters:
      key - The key of the ingredient
      itemStack - The ItemStack ingredient
      Returns:
      This Structure
    • addIngredient

      @Contract("_, _ -> this") @NotNull public @NotNull Structure addIngredient(char key, @NotNull @NotNull ItemProvider itemProvider)
      Adds an ItemProvider ingredient under the given key.
      Parameters:
      key - The key of the ingredient
      itemProvider - The ItemProvider ingredient
      Returns:
      This Structure
    • addIngredient

      @Contract("_, _ -> this") @NotNull public @NotNull Structure addIngredient(char key, @NotNull @NotNull Item item)
      Adds an Item ingredient under the given key.
      Parameters:
      key - The key of the ingredient
      item - The Item ingredient
      Returns:
      This Structure
    • addIngredient

      @Contract("_, _ -> this") @NotNull public @NotNull Structure addIngredient(char key, @NotNull @NotNull Inventory inventory)
      Adds a Inventory ingredient under the given key.
      Parameters:
      key - The key of the ingredient
      inventory - The Inventory ingredient
      Returns:
      This Structure
    • addIngredient

      @Contract("_, _, _ -> this") @NotNull public @NotNull Structure addIngredient(char key, @NotNull @NotNull Inventory inventory, @Nullable @Nullable ItemProvider background)
      Adds a Inventory ingredient under the given key.
      Parameters:
      key - The key of the ingredient
      inventory - The Inventory ingredient
      background - The background ItemProvider for the Inventory
      Returns:
      This Structure
    • addIngredient

      @Contract("_, _ -> this") @NotNull public @NotNull Structure addIngredient(char key, @NotNull @NotNull SlotElement element)
      Adds a Inventory ingredient under the given key.
      Parameters:
      key - The key of the ingredient
      element - The SlotElement ingredient
      Returns:
      This Structure
    • addIngredient

      @Contract("_, _ -> this") @NotNull public @NotNull Structure addIngredient(char key, @NotNull @NotNull Marker marker)
      Adds a Marker ingredient under the given key.
      Parameters:
      key - The key of the ingredient
      marker - The Marker ingredient
      Returns:
      This Structure
    • addIngredient

      @Contract("_, _ -> this") @NotNull public @NotNull Structure addIngredient(char key, @NotNull @NotNull Supplier<? extends Item> itemSupplier)
      Adds an ItemStack Supplier ingredient under the given key.
      Parameters:
      key - The key of the ingredient
      itemSupplier - The ItemStack Supplier ingredient
      Returns:
      This Structure
    • addIngredientElementSupplier

      @Contract("_, _ -> this") @NotNull public @NotNull Structure addIngredientElementSupplier(char key, @NotNull @NotNull Supplier<? extends SlotElement> elementSupplier)
      Adds a SlotElement Supplier ingredient under the given key.
      Parameters:
      key - The key of the ingredient
      elementSupplier - The SlotElement Supplier ingredient
      Returns:
      This Structure
    • getIngredientList

      @NotNull public @NotNull IngredientList getIngredientList()
      Gets the IngredientList for this Structure. Calling this method will lock the Structure and prevent further changes.
      Returns:
      The IngredientList
    • getWidth

      public int getWidth()
      Gets the width of this Structure.
      Returns:
      The width
    • getHeight

      public int getHeight()
      Gets the height of this Structure.
      Returns:
      The height
    • clone

      @Contract(value="-> new", pure=true) @NotNull public @NotNull Structure clone()
      Clones this Structure.
      Overrides:
      clone in class Object
      Returns:
      The cloned Structure