Package io.github.viimeinen1.ainventory
Class aInventory
java.lang.Object
io.github.viimeinen1.ainventory.aInventory
- All Implemented Interfaces:
org.bukkit.inventory.InventoryHolder
- Direct Known Subclasses:
aGUIInventory
Custom inventory with addinational features like reloading individual slots.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classItem builder foraInventory.static classaInventory.Builder<T extends aInventory.Builder<T,K>, K extends aInventory> Custom inventory builder.static classDefault inventory builder.static enumPossible inventory sizesstatic interfaceInventory close functionstatic interfaceGeneric inventory function.static interfacestatic interfaceclick functionstatic interfaceSingle item reload functionfinal classMessages of inventory.static interfaceInventory use requirement function -
Field Summary
FieldsModifier and TypeFieldDescriptionAll slot functions of this inventory.final org.bukkit.inventory.InventoryInventoryof this aInventory.All reload functions of this inventory.Owner of the inventory. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic aInventory.DefaultBuilderbuilder()Create newaInventory.DefaultBuilderfor building new inventory.org.bukkit.inventory.InventoryGetInventoryRe-Initialize inventory.static voidinitializeListener(@NotNull org.bukkit.plugin.java.JavaPlugin plugin) Initialize listener for aInventory.ItemBuilder(@org.jetbrains.annotations.NotNull int slot) Modify slot.ItemBuilder(@NotNull Collection<Integer> slots) Modify multiple slots.voidonInventoryClick(@NotNull org.bukkit.event.inventory.InventoryClickEvent event) voidonInventoryClose(@NotNull org.bukkit.event.inventory.InventoryCloseEvent event) voidonInventoryOpen(@NotNull org.bukkit.event.inventory.InventoryOpenEvent event) voidonInventoryTransfer(@NotNull org.bukkit.event.inventory.InventoryClickEvent event) booleanopenInventory(@NotNull org.bukkit.entity.HumanEntity player) Open inventory for player.reload()Runs reload function of all slots in the inventory.Runs reload function for specific slot.update()Update inventory for all it's viewers.
-
Field Details
-
inventory
public final org.bukkit.inventory.Inventory inventoryInventoryof this aInventory. Modify this if more control is needed. -
owner
Owner of the inventory. If set, no other player can open or use the inventory. -
clickFunctions
All slot functions of this inventory. -
itemReloads
All reload functions of this inventory.
-
-
Constructor Details
-
aInventory
Create newaInventory. PreferaInventory.Builder.build()to build new inventory.- Parameters:
builder- extendsaInventory.Builder
-
-
Method Details
-
getInventory
public org.bukkit.inventory.Inventory getInventory()GetInventory- Specified by:
getInventoryin interfaceorg.bukkit.inventory.InventoryHolder
-
openInventory
public boolean openInventory(@NotNull @NotNull org.bukkit.entity.HumanEntity player) Open inventory for player. Will sendaInventory.Messages.NO_OPEN_PERMISSIONif no permission to open inventory. Permission will be determined by: - Checking if playerUUIDmatches the owner of the inventory. - RunningaInventory.requirementFunctionlinked 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
Re-Initialize inventory. Will: - clear inventory. - run initialization function again. - update inventory to all it's viewers.- Returns:
aInventory
-
reload
Runs reload function of all slots in the inventory.- Returns:
aInventory
-
reload
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
Update inventory for all it's viewers.- Returns:
aInventory
-
builder
Create newaInventory.DefaultBuilderfor building new inventory.- Returns:
- new
aInventory.DefaultBuilder
-
ItemBuilder
Modify slot.- Parameters:
slot- slot number- Returns:
- new item builder
-
ItemBuilder
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-JavaPluginthat the listener will be listed for.
-