Class aInventory

java.lang.Object
io.github.viimeinen1.ainventory.aInventory
All Implemented Interfaces:
org.bukkit.inventory.InventoryHolder
Direct Known Subclasses:
aGUIInventory

public class aInventory extends Object implements org.bukkit.inventory.InventoryHolder
Custom inventory with addinational features like reloading individual slots.
  • Field Details

    • inventory

      public final org.bukkit.inventory.Inventory inventory
      Inventory of this aInventory. Modify this if more control is needed.
    • owner

      public UUID owner
      Owner of the inventory. If set, no other player can open or use the inventory.
    • clickFunctions

      public final Map<Integer,aInventory.itemClickFunction> clickFunctions
      All slot functions of this inventory.
    • itemReloads

      public final Map<Integer,aInventory.itemReloadFunction> itemReloads
      All reload functions of this inventory.
  • Constructor Details

  • Method Details

    • getInventory

      public org.bukkit.inventory.Inventory getInventory()
      Get Inventory
      Specified by:
      getInventory in interface org.bukkit.inventory.InventoryHolder
    • openInventory

      public boolean openInventory(@NotNull @NotNull org.bukkit.entity.HumanEntity player)
      Open inventory for player. Will send aInventory.Messages.NO_OPEN_PERMISSION if no permission to open inventory. Permission will be determined by: - Checking if player UUID matches the owner of the inventory. - Running aInventory.requirementFunction linked to this inventory. Will also reload the inventory before it's openend.
      Parameters:
      player - Who the inventory will be opened to.
      Returns:
      true if inventory was opened for player.
    • initialize

      public aInventory initialize()
      Re-Initialize inventory. Will: - clear inventory. - run initialization function again. - update inventory to all it's viewers.
      Returns:
      aInventory
    • reload

      public aInventory reload()
      Runs reload function of all slots in the inventory.
      Returns:
      aInventory
    • reload

      public aInventory reload(@NotNull @NotNull Integer slot)
      Runs reload function for specific slot.
      Parameters:
      slot - slot to run reload on
      Returns:
      aInventory
    • onInventoryClick

      @Internal public void onInventoryClick(@NotNull @NotNull org.bukkit.event.inventory.InventoryClickEvent event)
    • onInventoryTransfer

      @Internal public void onInventoryTransfer(@NotNull @NotNull org.bukkit.event.inventory.InventoryClickEvent event)
    • onInventoryOpen

      @Internal public void onInventoryOpen(@NotNull @NotNull org.bukkit.event.inventory.InventoryOpenEvent event)
    • onInventoryClose

      @Internal public void onInventoryClose(@NotNull @NotNull org.bukkit.event.inventory.InventoryCloseEvent event)
    • update

      public aInventory update()
      Update inventory for all it's viewers.
      Returns:
      aInventory
    • builder

      public static aInventory.DefaultBuilder builder()
      Create new aInventory.DefaultBuilder for building new inventory.
      Returns:
      new aInventory.DefaultBuilder
    • ItemBuilder

      public aInventory.aItemBuilder ItemBuilder(@NotNull @org.jetbrains.annotations.NotNull int slot)
      Modify slot.
      Parameters:
      slot - slot number
      Returns:
      new item builder
    • ItemBuilder

      public aInventory.aItemBuilder ItemBuilder(@NotNull @NotNull Collection<Integer> slots)
      Modify multiple slots. All previous parameters will be taken from the first item in the list and copied to all slots. (name, lore, amount, material etc.)
      Parameters:
      slots - slot numbers
      Returns:
      new item builder
    • initializeListener

      public static void initializeListener(@NotNull @NotNull org.bukkit.plugin.java.JavaPlugin plugin)
      Initialize listener for aInventory. Without initializing the listener, the click functions will not work.
      Parameters:
      plugin - JavaPlugin that the listener will be listed for.