Class aInventory.aItemBuilder

java.lang.Object
io.github.viimeinen1.ainventory.aInventory.aItemBuilder
Enclosing class:
aInventory

public static class aInventory.aItemBuilder extends Object
Item builder for aInventory. Supports reload functions.
  • Constructor Details

    • aItemBuilder

      public aItemBuilder(@NotNull @NotNull aInventory inventory, @NotNull @org.jetbrains.annotations.NotNull int slot)
      Modify single slot. If slot already exists, the item will copy it's values. Prefer aInventory.ItemBuilder(int)
      Parameters:
      inventory - Inventory that the item(s) will be set to.
      slot - slot number
    • aItemBuilder

      public aItemBuilder(@NotNull @NotNull aInventory inventory, @NotNull @NotNull Collection<Integer> slots)
      Modify multiple slots. All previous parameters will be taken from the first item in the list. Prefer aInventory.ItemBuilder(Collection)
      Parameters:
      inventory - Inventory that the item(s) will be set to.
      slots - slot numbers
  • Method Details

    • addSlot

      public aInventory.aItemBuilder addSlot(@NotNull @NotNull Integer slot)
      Add slot that the item(s) will be copied to.
      Parameters:
      slot - slot number
      Returns:
      builder
    • addSlot

      public aInventory.aItemBuilder addSlot(@NotNull @NotNull Collection<Integer> slots)
      Add multiple slots that this item(s) will be copied to.
      Parameters:
      slots - slot numbers
      Returns:
      builder
    • setItem

      public aInventory.aItemBuilder setItem(@NotNull @NotNull org.bukkit.inventory.ItemStack item)
      Replace item in the builder. This will discard all item related values added before.
      Parameters:
      item - ItemStack
      Returns:
      builder
    • getInventory

      public aInventory getInventory()
      Get aInventory the item(s) will be set to.
      Returns:
      the aInventory the items will be set to.
    • getSlots

      public Set<Integer> getSlots()
      Get slots that item(s) will be copied to.
      Returns:
      List of slot numbers
    • removeSlotFuntion

      public aInventory.aItemBuilder removeSlotFuntion(boolean removeSlotFuntion)
      If slot Function should be removed. Will be ignored if new slot function is added.
      Parameters:
      removeSlotFuntion - boolean if slot function should be removed.
      Returns:
      builder
    • removeReloadFunction

      public aInventory.aItemBuilder removeReloadFunction(boolean removeReloadFunction)
      If reload function should be removed. Will be ignored if new reload function is added.
      Parameters:
      removeReloadFunction - boolean if reload function should be removed.
      Returns:
      builder
    • material

      public aInventory.aItemBuilder material(@NotNull @NotNull org.bukkit.Material material)
      Set the type of the item(s).
      Parameters:
      material - new Material for item(s).
      Returns:
      builder
    • amount

      public aInventory.aItemBuilder amount(@NotNull @NotNull Integer amount)
      Set amount for item(s).
      Parameters:
      amount - amount for item(s).
      Returns:
      builder
    • clear

      public aInventory.aItemBuilder clear()
      Clear item(s) completely. Material will be set to AIR.
      Returns:
      builder
    • reload

      public aInventory.aItemBuilder reload(@Nullable @Nullable aInventory.itemReloadFunction fn)
      Reload function. The function will be called every time inventory is opened. Using null will cause the function to not change. Use removeReloadFunction(boolean) to remove reload function.
      Parameters:
      fn - reload function
      Returns:
      builder
    • name

      public <K> aInventory.aItemBuilder name(@Nullable K name, @NotNull @org.jetbrains.annotations.NotNull boolean italic)
      Set displayname of item(s). Using null will retain old displayname. Accepts both String and Component. Giving object with other types will fail silently. If String, the string will be deserialized as minimessage.
      Type Parameters:
      K - String or Component
      Parameters:
      name - displayname of item(s)
      italic - if name should be italic (default true)
      Returns:
      builder
    • lore

      public <K> aInventory.aItemBuilder lore(@Nullable @Nullable Collection<K> loreLines, @NotNull @org.jetbrains.annotations.NotNull boolean italic)
      Set lore of item(s). Using null will do nothing. Accepts both String and Component. If other types are used, those lines will be skipped.
      Type Parameters:
      K - String or Component
      Parameters:
      loreLines - lines
      italic - if lore should be italic
      Returns:
      builder
    • function

      public aInventory.aItemBuilder function(@Nullable @Nullable aInventory.itemClickFunction slotFn)
      Function that is run when item(s) is clicked. Using null will keep original function. Use removeSlotFuntion(boolean) to remove slot function.
      Parameters:
      slotFn -
      invalid reference
      itemClickEvent
      Returns:
      builder
    • setData

      public <K> aInventory.aItemBuilder setData(@NotNull io.papermc.paper.datacomponent.DataComponentType.Valued<K> type, @NotNull K value)
      Set data component to item(s).
      Parameters:
      type - component type
      value - component value
      Returns:
      builder
    • build

      public aInventory build()
      Apply item(s) to linked inventory. If not called, all changes to builder will be discarded.
      Returns:
      aInventory that the item(s) were set to.
    • name

      public aInventory.aItemBuilder name(String string)