Class CustomInventory

java.lang.Object
me.yleoft.zAPI.inventory.CustomInventory

public class CustomInventory extends Object
CustomInventory class to create a custom inventory with a specified name and number of rows. The inventory can hold items and can be retrieved as an Inventory object.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static String
     
    static String
     
    static String
    The mark used to identify items in the inventory.
  • Constructor Summary

    Constructors
    Constructor
    Description
    CustomInventory(@NotNull String inventoryName, int rows)
    Creates a custom inventory with the specified name and number of rows.
    CustomInventory(@NotNull org.bukkit.configuration.file.YamlConfiguration config)
     
    CustomInventory(@Nullable org.bukkit.entity.Player player, @NotNull org.bukkit.configuration.file.YamlConfiguration config)
    Creates a custom inventory from a YamlConfiguration file.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.bukkit.inventory.Inventory
    Creates and returns the final inventory
    @NotNull String
    Gets the name of the inventory.
    int
    Gets the number of rows in the inventory.
    void
    removeItem(int slot)
    Removes an item from the inventory at the specified slot.
    void
    setInventoryName(@NotNull String inventoryName)
     
    void
    setInventoryName(@Nullable org.bukkit.OfflinePlayer player, @NotNull String inventoryName)
    Sets the name of the inventory.
    void
    setItem(int slot, @NotNull org.bukkit.inventory.ItemStack item)
     
    void
    setItem(int slot, @NotNull org.bukkit.inventory.ItemStack item, @NotNull String command)
     
    void
    setItem(int slot, @NotNull org.bukkit.inventory.ItemStack item, @NotNull String command, @Nullable HashMap<String,String> replaces)
     
    void
    setItem(int slot, @NotNull org.bukkit.inventory.ItemStack item, @NotNull List<String> commands, @Nullable HashMap<String,String> replaces)
    Adds an item to the inventory at the specified slot.
    void
    setItem(int slot, @NotNull org.bukkit.inventory.ItemStack item, @Nullable HashMap<String,String> replaces)
     
    void
    setItem(@Nullable org.bukkit.configuration.file.YamlConfiguration config, @Nullable String materialPath, @NotNull String slot, @NotNull org.bukkit.inventory.ItemStack item, @Nullable HashMap<String,String> replaces)
     
    void
    setItem(@Nullable org.bukkit.entity.Player player, @NotNull org.bukkit.configuration.file.YamlConfiguration config, @NotNull String path, @Nullable String replace, @Nullable List<String> replacers)
     
    void
    setItem(@Nullable org.bukkit.entity.Player player, @NotNull org.bukkit.configuration.file.YamlConfiguration config, @NotNull String path, @Nullable String replace, @Nullable List<String> replacers, boolean addIfEmpty)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • mark

      public static String mark
      The mark used to identify items in the inventory.
    • configPathInventory

      public static String configPathInventory
    • configPathItems

      public static String configPathItems
  • Constructor Details

    • CustomInventory

      public CustomInventory(@NotNull @NotNull String inventoryName, int rows)
      Creates a custom inventory with the specified name and number of rows.
      Parameters:
      inventoryName - The name of the inventory.
      rows - The number of rows (1-6).
      Throws:
      IllegalArgumentException - if the number of rows is not between 1 and 6.
    • CustomInventory

      public CustomInventory(@Nullable @Nullable org.bukkit.entity.Player player, @NotNull @NotNull org.bukkit.configuration.file.YamlConfiguration config)
      Creates a custom inventory from a YamlConfiguration file.
      Parameters:
      config - The YamlConfiguration file to load the inventory from.
    • CustomInventory

      public CustomInventory(@NotNull @NotNull org.bukkit.configuration.file.YamlConfiguration config)
  • Method Details

    • setItem

      public void setItem(int slot, @NotNull @NotNull org.bukkit.inventory.ItemStack item, @NotNull @NotNull List<String> commands, @Nullable @Nullable HashMap<String,String> replaces)
      Adds an item to the inventory at the specified slot.
      Parameters:
      slot - The slot to add the item to (0-53).
      item - The item to add.
      Throws:
      IllegalArgumentException - if the slot is out of bounds.
    • setItem

      public void setItem(int slot, @NotNull @NotNull org.bukkit.inventory.ItemStack item, @NotNull @NotNull String command, @Nullable @Nullable HashMap<String,String> replaces)
    • setItem

      public void setItem(int slot, @NotNull @NotNull org.bukkit.inventory.ItemStack item, @NotNull @NotNull String command)
    • setItem

      public void setItem(int slot, @NotNull @NotNull org.bukkit.inventory.ItemStack item, @Nullable @Nullable HashMap<String,String> replaces)
    • setItem

      public void setItem(int slot, @NotNull @NotNull org.bukkit.inventory.ItemStack item)
    • setItem

      public void setItem(@Nullable @Nullable org.bukkit.configuration.file.YamlConfiguration config, @Nullable @Nullable String materialPath, @NotNull @NotNull String slot, @NotNull @NotNull org.bukkit.inventory.ItemStack item, @Nullable @Nullable HashMap<String,String> replaces)
    • setItem

      public void setItem(@Nullable @Nullable org.bukkit.entity.Player player, @NotNull @NotNull org.bukkit.configuration.file.YamlConfiguration config, @NotNull @NotNull String path, @Nullable @Nullable String replace, @Nullable @Nullable List<String> replacers, boolean addIfEmpty)
    • setItem

      public void setItem(@Nullable @Nullable org.bukkit.entity.Player player, @NotNull @NotNull org.bukkit.configuration.file.YamlConfiguration config, @NotNull @NotNull String path, @Nullable @Nullable String replace, @Nullable @Nullable List<String> replacers)
    • removeItem

      public void removeItem(int slot)
      Removes an item from the inventory at the specified slot.
      Parameters:
      slot - The slot to remove the item from (0-53).
      Throws:
      IllegalArgumentException - if the slot is out of bounds.
    • setInventoryName

      public void setInventoryName(@Nullable @Nullable org.bukkit.OfflinePlayer player, @NotNull @NotNull String inventoryName)
      Sets the name of the inventory.
      Parameters:
      inventoryName - The name of the inventory.
    • setInventoryName

      public void setInventoryName(@NotNull @NotNull String inventoryName)
    • getInventoryName

      @NotNull public @NotNull String getInventoryName()
      Gets the name of the inventory.
      Returns:
      The name of the inventory.
    • getRows

      public int getRows()
      Gets the number of rows in the inventory.
      Returns:
      The number of rows in the inventory.
    • getInventory

      public org.bukkit.inventory.Inventory getInventory()
      Creates and returns the final inventory
      Returns:
      The created inventory.