Class InventoryManager
java.lang.Object
io.github.rysefoxx.inventory.plugin.pagination.InventoryManager
- Since:
- 2/17/2022
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassIt's a class that listens for events and cancels them if the player is viewing a RyseInventory -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddToCache(RyseInventory ryseInventory) Saves the inventory to the cache.boolean@NotNull List<IntelligentItem>getAllItemsById(@NotNull Object id) @NotNull Optional<InventoryContents>getContents(@NotNull UUID uuid) With this method you can get the inventory content from the player.@NotNull Optional<RyseInventory>getInventory(@NotNull Object identifier) With this method you can get the inventory from the inventory identifier.@NotNull Optional<RyseInventory>getInventory(@NotNull UUID uuid) With this method you can get the inventory from the player.@Nullable IntelligentItemgetItemById(@NotNull Object id) @NotNull Optional<RyseInventory>getLastInventory(@NotNull UUID uuid) Get the last inventory that the player had open.getOpenedPlayers(@NotNull RyseInventory inventory) Get all players who have a certain inventory openvoidinvoke()Registers the standard eventsprotected voidinvokeScheduler(@NotNull org.bukkit.entity.Player player, @NotNull RyseInventory inventory) If the player has an inventory, and the inventory is the same as the one passed in, then update the inventoryvoidregister(@NotNull IntelligentItem item) Adds the IntelligentItem to the list if this item has an ID.protected voidremoveInventory(@NotNull UUID uuid) It removes the inventory of the player with the given UUID from the HashMapprotected voidremoveInventoryFromPlayer(@NotNull UUID uuid) Removes the inventory from the playervoidsetContents(@NotNull UUID uuid, @NotNull InventoryContents contents) It puts the contents of the inventory into a HashMapprotected voidsetInventory(@NotNull UUID uuid, @NotNull RyseInventory inventory) This function sets the inventory of a player.protected voidsetLastInventory(@NotNull UUID uuid, @NotNull RyseInventory inventory, @NotNull RyseInventory newInventory) It adds the player's current inventory to a list of inventoriesvoidsetLastOpen(UUID uuid) protected voidstopUpdate(@NotNull UUID uuid) It stops the update task for the specified player
-
Constructor Details
-
InventoryManager
public InventoryManager()
-
-
Method Details
-
canOpen
-
setLastOpen
-
register
Adds the IntelligentItem to the list if this item has an ID.- Parameters:
item- The item to add.- Throws:
NullPointerException- If the item ID is null.
-
getItemById
- Parameters:
id- The id of the item- Returns:
- Returns the first IntelligentItem that matches the ID. If no item is found, null is returned.
-
getAllItemsById
- Parameters:
id- The id of the item- Returns:
- Returns all IntelligentItems that match the ID. If no item is found, an empty list is returned.
-
getInventory
With this method you can get the inventory from the player.- Parameters:
uuid- The UUID of the player.- Returns:
- null if the player has no inventory open.
-
getOpenedPlayers
Get all players who have a certain inventory open- Parameters:
inventory- The inventory that is filtered by.- Returns:
- The list with all found players.
-
getLastInventory
Get the last inventory that the player had open.- Parameters:
uuid- Player UUID- Returns:
- null if there is no final inventory.
-
getInventory
With this method you can get the inventory from the inventory identifier.- Parameters:
identifier- The ID to identify- Returns:
- null if no inventory with the ID could be found.
Only works if the inventory has also been assigned an identifier.
-
getContents
With this method you can get the inventory content from the player.- Parameters:
uuid- The UUID of the player.- Returns:
- the player inventory content.
-
invoke
public void invoke()Registers the standard events -
removeInventoryFromPlayer
Removes the inventory from the player- Parameters:
uuid- The UUID of the player to remove the inventory from.
-
removeInventory
It removes the inventory of the player with the given UUID from the HashMap- Parameters:
uuid- The UUID of the player to remove the inventory of.
-
setContents
@Internal public void setContents(@NotNull @NotNull UUID uuid, @NotNull @NotNull InventoryContents contents) It puts the contents of the inventory into a HashMap- Parameters:
uuid- The UUID of the player who's inventory you want to set.contents- The InventoryContents object that you want to set.
-
setInventory
This function sets the inventory of a player.- Parameters:
uuid- The UUID of the playerinventory- The inventory to set.
-
setLastInventory
protected void setLastInventory(@NotNull @NotNull UUID uuid, @NotNull @NotNull RyseInventory inventory, @NotNull @NotNull RyseInventory newInventory) It adds the player's current inventory to a list of inventories- Parameters:
uuid- The UUID of the playerinventory- The inventory that the player is currently in.newInventory- The new inventory that the player is switching to.
-
stopUpdate
It stops the update task for the specified player- Parameters:
uuid- The UUID of the player to stop updating.
-
invokeScheduler
protected void invokeScheduler(@NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull RyseInventory inventory) If the player has an inventory, and the inventory is the same as the one passed in, then update the inventory- Parameters:
player- The player who's inventory is being updated.inventory- The inventory that will be updated.
-
addToCache
Saves the inventory to the cache.- Parameters:
ryseInventory- The inventory to save.
-