Class InventoryManager

java.lang.Object
io.github.rysefoxx.inventory.plugin.pagination.InventoryManager

public class InventoryManager extends Object
Since:
2/17/2022
  • Constructor Details

    • InventoryManager

      public InventoryManager()
  • Method Details

    • canOpen

      public boolean canOpen(UUID uuid)
    • setLastOpen

      public void setLastOpen(UUID uuid)
    • register

      public void register(@NotNull @NotNull IntelligentItem item) throws NullPointerException
      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

      @Nullable public @Nullable IntelligentItem getItemById(@NotNull @NotNull Object id)
      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

      @NotNull public @NotNull List<IntelligentItem> getAllItemsById(@NotNull @NotNull Object id)
      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

      @NotNull public @NotNull Optional<RyseInventory> getInventory(@NotNull @NotNull UUID uuid)
      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

      @NotNull public @NotNull List<UUID> getOpenedPlayers(@NotNull @NotNull RyseInventory inventory)
      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

      @NotNull public @NotNull Optional<RyseInventory> getLastInventory(@NotNull @NotNull UUID uuid)
      Get the last inventory that the player had open.
      Parameters:
      uuid - Player UUID
      Returns:
      null if there is no final inventory.
    • getInventory

      @NotNull public @NotNull Optional<RyseInventory> getInventory(@NotNull @NotNull Object identifier)
      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

      @NotNull public @NotNull Optional<InventoryContents> getContents(@NotNull @NotNull UUID uuid)
      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

      protected void removeInventoryFromPlayer(@NotNull @NotNull UUID uuid)
      Removes the inventory from the player
      Parameters:
      uuid - The UUID of the player to remove the inventory from.
    • removeInventory

      protected void removeInventory(@NotNull @NotNull UUID uuid)
      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

      protected void setInventory(@NotNull @NotNull UUID uuid, @NotNull @NotNull RyseInventory inventory)
      This function sets the inventory of a player.
      Parameters:
      uuid - The UUID of the player
      inventory - 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 player
      inventory - The inventory that the player is currently in.
      newInventory - The new inventory that the player is switching to.
    • stopUpdate

      protected void stopUpdate(@NotNull @NotNull UUID uuid)
      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

      protected void addToCache(RyseInventory ryseInventory)
      Saves the inventory to the cache.
      Parameters:
      ryseInventory - The inventory to save.