Package io.github.viimeinen1.ainventory
Class aInventory.aItemBuilder
java.lang.Object
io.github.viimeinen1.ainventory.aInventory.aItemBuilder
- Enclosing class:
aInventory
Item builder for
aInventory. Supports reload functions.-
Constructor Summary
ConstructorsConstructorDescriptionaItemBuilder(@NotNull aInventory inventory, @org.jetbrains.annotations.NotNull int slot) Modify single slot.aItemBuilder(@NotNull aInventory inventory, @NotNull Collection<Integer> slots) Modify multiple slots. -
Method Summary
Modifier and TypeMethodDescriptionAdd slot that the item(s) will be copied to.addSlot(@NotNull Collection<Integer> slots) Add multiple slots that this item(s) will be copied to.Set amount for item(s).build()Apply item(s) to linked inventory.clear()Clear item(s) completely.function(@Nullable aInventory.itemClickFunction slotFn) Function that is run when item(s) is clicked.GetaInventorythe item(s) will be set to.getSlots()Get slots that item(s) will be copied to.lore(@Nullable Collection<K> loreLines, @org.jetbrains.annotations.NotNull boolean italic) Set lore of item(s).material(@NotNull org.bukkit.Material material) Set the type of the item(s).name(K name, @org.jetbrains.annotations.NotNull boolean italic) Set displayname of item(s).reload(@Nullable aInventory.itemReloadFunction fn) Reload function.removeReloadFunction(boolean removeReloadFunction) If reload function should be removed.removeSlotFuntion(boolean removeSlotFuntion) If slot Function should be removed.setData(io.papermc.paper.datacomponent.DataComponentType.Valued<K> type, K value) Set data component to item(s).setItem(@NotNull org.bukkit.inventory.ItemStack item) Replace item in the builder.
-
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. PreferaInventory.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. PreferaInventory.ItemBuilder(Collection)- Parameters:
inventory- Inventory that the item(s) will be set to.slots- slot numbers
-
-
Method Details
-
addSlot
Add slot that the item(s) will be copied to.- Parameters:
slot- slot number- Returns:
- builder
-
addSlot
Add multiple slots that this item(s) will be copied to.- Parameters:
slots- slot numbers- Returns:
- builder
-
setItem
Replace item in the builder. This will discard all item related values added before.- Parameters:
item-ItemStack- Returns:
- builder
-
getInventory
GetaInventorythe item(s) will be set to.- Returns:
- the
aInventorythe items will be set to.
-
getSlots
Get slots that item(s) will be copied to.- Returns:
Listof slot numbers
-
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
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
Set the type of the item(s).- Parameters:
material- newMaterialfor item(s).- Returns:
- builder
-
amount
Set amount for item(s).- Parameters:
amount- amount for item(s).- Returns:
- builder
-
clear
Clear item(s) completely. Material will be set to AIR.- Returns:
- builder
-
reload
Reload function. The function will be called every time inventory is opened. Using null will cause the function to not change. UseremoveReloadFunction(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 bothStringandComponent. Giving object with other types will fail silently. IfString, the string will be deserialized as minimessage.- Type Parameters:
K-StringorComponent- 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 bothStringandComponent. If other types are used, those lines will be skipped.- Type Parameters:
K-StringorComponent- Parameters:
loreLines- linesitalic- if lore should be italic- Returns:
- builder
-
function
Function that is run when item(s) is clicked. Using null will keep original function. UseremoveSlotFuntion(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 typevalue- component value- Returns:
- builder
-
build
Apply item(s) to linked inventory. If not called, all changes to builder will be discarded.- Returns:
aInventorythat the item(s) were set to.
-
name
-