Interface InventoryManager

All Superinterfaces:
org.bukkit.event.Listener, fr.maxlego08.menu.zcore.utils.storage.Savable

public interface InventoryManager extends fr.maxlego08.menu.zcore.utils.storage.Savable, org.bukkit.event.Listener

Inventory Management:

  • Loading
  • Deletion
  • Opening
  • etc...

API example here: https://docs.zmenu.dev/api/create-inventory

  • Method Details

    • loadInventoryOrSaveResource

      Inventory loadInventoryOrSaveResource(org.bukkit.plugin.Plugin plugin, String fileName) throws fr.maxlego08.menu.exceptions.InventoryException
      Loads an inventory. The plugin will retrieve the resource of your plugin to save it if it does not exist.
      Parameters:
      plugin - The plugin loading the inventory.
      fileName - Name of the file where the inventory is located.
      Returns:
      New Inventory.
      Throws:
      fr.maxlego08.menu.exceptions.InventoryException - Error loading inventory.
    • loadInventoryOrSaveResource

      Inventory loadInventoryOrSaveResource(org.bukkit.plugin.Plugin plugin, String fileName, Class<? extends Inventory> classz) throws fr.maxlego08.menu.exceptions.InventoryException
      Loads an inventory. The plugin will retrieve the resource of your plugin to save it if it does not exist. You must add the class of your plugin as a parameter. More information about custom class here
      Parameters:
      plugin - The plugin loading the inventory.
      fileName - Name of the file where the inventory is located.
      classz - Class that will be used for the inventory; by default, it will be ZInventory.
      Returns:
      New Inventory.
      Throws:
      fr.maxlego08.menu.exceptions.InventoryException - Error loading inventory.
    • loadInventory

      Inventory loadInventory(org.bukkit.plugin.Plugin plugin, String fileName, Class<? extends Inventory> classz) throws fr.maxlego08.menu.exceptions.InventoryException
      Loads an inventory from a file. You must add the class of your plugin as a parameter. More information about custom class here
      Parameters:
      plugin - The plugin loading the inventory.
      fileName - Name of the file where the inventory is located.
      classz - Class that will be used for the inventory; by default, it will be ZInventory.
      Returns:
      New Inventory.
      Throws:
      fr.maxlego08.menu.exceptions.InventoryException - Error loading inventory.
    • loadInventory

      Inventory loadInventory(org.bukkit.plugin.Plugin plugin, File file, Class<? extends Inventory> classz) throws fr.maxlego08.menu.exceptions.InventoryException
      Loads an inventory from a file. You must add the class of your plugin as a parameter.
      Parameters:
      plugin - The plugin loading the inventory.
      file - File where the inventory is located.
      classz - Class that will be used for the inventory; by default, it will be ZInventory.
      Returns:
      New Inventory.
      Throws:
      fr.maxlego08.menu.exceptions.InventoryException - Error loading inventory.
    • loadInventory

      Inventory loadInventory(org.bukkit.plugin.Plugin plugin, String fileName) throws fr.maxlego08.menu.exceptions.InventoryException
      Loads an inventory from a file. You must add the class of your plugin as a parameter.
      Parameters:
      plugin - The plugin loading the inventory.
      fileName - Name of the file where the inventory is located.
      Returns:
      New Inventory.
      Throws:
      fr.maxlego08.menu.exceptions.InventoryException - Error loading inventory.
    • loadInventory

      Inventory loadInventory(org.bukkit.plugin.Plugin plugin, File file) throws fr.maxlego08.menu.exceptions.InventoryException
      Loads an inventory from a file. You must add the class of your plugin as a parameter.
      Parameters:
      plugin - The plugin loading the inventory.
      file - File where the inventory is located.
      Returns:
      New Inventory.
      Throws:
      fr.maxlego08.menu.exceptions.InventoryException - Error loading inventory.
    • getInventory

      Optional<Inventory> getInventory(String name)
      Returns an optional of Inventory based on its name.
      Parameters:
      name - Inventory name.
      Returns:
      Optional of Inventory.
    • getInventory

      Optional<Inventory> getInventory(org.bukkit.plugin.Plugin plugin, String name)
      Returns an optional of Inventory based on its name and the plugin.
      Parameters:
      plugin - The plugin where the inventory comes from.
      name - Inventory name.
      Returns:
      Optional of Inventory.
    • getInventory

      Optional<Inventory> getInventory(String pluginName, String name)
      Returns an optional of Inventory based on its name and the plugin name.
      Parameters:
      pluginName - The plugin name where the inventory comes from.
      name - Inventory name.
      Returns:
      Optional of Inventory.
    • getInventories

      Collection<Inventory> getInventories()
      Returns a collection of all loaded inventories.
      Returns:
      Collection of Inventory.
    • getInventories

      Collection<Inventory> getInventories(org.bukkit.plugin.Plugin plugin)
      Returns a collection of inventories loaded from a specific plugin.
      Parameters:
      plugin - The plugin.
      Returns:
      Inventories.
    • deleteInventory

      void deleteInventory(Inventory inventory)
      Deletes an inventory.
      Parameters:
      inventory - Inventory to be deleted.
    • deleteInventory

      boolean deleteInventory(String name)
      Deletes an inventory based on its name.
      Parameters:
      name - Inventory name.
      Returns:
      True if the inventory has been deleted.
    • deleteInventories

      void deleteInventories(org.bukkit.plugin.Plugin plugin)
      Deletes all inventories loaded from a plugin.
      Parameters:
      plugin - The plugin.
    • openInventory

      void openInventory(org.bukkit.entity.Player player, Inventory inventory)
      Opens an inventory for a player.
      Parameters:
      player - Player to whom the inventory must be opened.
      inventory - The inventory to be opened.
    • openInventory

      void openInventory(org.bukkit.entity.Player player, Inventory inventory, int page)
      Opens an inventory for a player on a specific page.
      Parameters:
      player - Player to whom the inventory must be opened.
      inventory - The inventory to be opened.
      page - Inventory page.
    • openInventory

      void openInventory(org.bukkit.entity.Player player, Inventory inventory, int page, List<Inventory> oldInventories)
      Opens an inventory for a player on a specific page with old inventories.
      Parameters:
      player - Player to whom the inventory must be opened.
      inventory - The inventory to be opened.
      page - Inventory page.
      oldInventories - List of old inventories.
    • openInventory

      void openInventory(org.bukkit.entity.Player player, Inventory inventory, int page, Inventory... inventories)
      Opens an inventory for a player on a specific page with old inventories.
      Parameters:
      player - Player to whom the inventory must be opened.
      inventory - The inventory to be opened.
      page - Inventory page.
      inventories - List of old inventories.
    • loadButtons

      void loadButtons()
      Loads buttons. The ButtonLoaderRegisterEvent event will be called, allowing you to add your own buttons using this event.
    • loadInventories

      void loadInventories()
      Loads inventories of the plugin.
    • registerMaterialLoader

      boolean registerMaterialLoader(MaterialLoader materialLoader)
      Registers a material loader.
      Parameters:
      materialLoader - New material loader.
      Returns:
      True if registered.
    • getMaterialLoader

      Optional<MaterialLoader> getMaterialLoader(String key)
      Returns a material loader based on a key.
      Parameters:
      key - The key to identify the material loader.
      Returns:
      Optional of MaterialLoader.
    • getMaterialLoader

      Collection<MaterialLoader> getMaterialLoader()
      Returns a list of material loaders.
      Returns:
      List of MaterialLoader.
    • openInventory

      void openInventory(org.bukkit.entity.Player player, org.bukkit.plugin.Plugin plugin, String inventoryName)
      Opens an inventory based on its name and the plugin.
      Parameters:
      player - Player who will open the inventory.
      plugin - The plugin where the inventory comes from.
      inventoryName - Name of the inventory to be opened.
    • openInventory

      void openInventory(org.bukkit.entity.Player player, String pluginName, String inventoryName)
      Opens an inventory based on its name and the plugin name.
      Parameters:
      player - Player who will open the inventory.
      pluginName - The plugin where the inventory comes from.
      inventoryName - Name of the inventory to be opened.
    • openInventory

      void openInventory(org.bukkit.entity.Player player, String inventoryName)
      Opens an inventory based on its name. Note that this method searches in all inventories; it is more appropriate to use the method openInventory(Player, Plugin, String).
      Parameters:
      player - Player who will open the inventory.
      inventoryName - Name of the inventory to be opened.
    • getPluginIgnoreCase

      Optional<org.bukkit.plugin.Plugin> getPluginIgnoreCase(String pluginName)
      Returns an optional of a plugin based on its name.
      Parameters:
      pluginName - The name of the plugin to be found.
      Returns:
      Optional of a plugin that can contain the plugin if it exists.
    • reloadInventory

      void reloadInventory(Inventory inventory)
      Reloads the configuration of an inventory.
      Parameters:
      inventory - The inventory that needs to be reloaded.
    • getMeta

      MetaUpdater getMeta()
      Sets item name and item meta using Spigot or Adventure API.
      Returns:
      MetaUpdater.
    • getCurrentPlayerInventory

      Optional<Inventory> getCurrentPlayerInventory(org.bukkit.entity.Player player)
      Gets the current open inventory of a player.
      Parameters:
      player - Player whose inventory is checked.
      Returns:
      Optional of inventory.
    • unregisterListener

      void unregisterListener(org.bukkit.plugin.Plugin plugin)
      Unregisters a FastEvent listener.
      Parameters:
      plugin - The plugin.
    • registerFastEvent

      void registerFastEvent(org.bukkit.plugin.Plugin plugin, FastEvent fastEvent)
      Adds a FastEvent listener, which is faster than Bukkit events.
      Parameters:
      plugin - The plugin.
      fastEvent - The fastEvent.
    • getFastEvents

      Collection<FastEvent> getFastEvents()
      Gets the FastEvents.
      Returns:
      Listeners.
    • sendInventories

      void sendInventories(org.bukkit.command.CommandSender sender)
      Displays the list of available inventories.
      Parameters:
      sender - Command sender.
    • createNewInventory

      void createNewInventory(org.bukkit.command.CommandSender sender, String fileName, int inventorySize, String inventoryName)
      Creates a new inventory file.
      Parameters:
      sender - Command sender.
      fileName - Inventory file name.
      inventorySize - Inventory size.
      inventoryName - Inventory name.
    • updateInventory

      void updateInventory(org.bukkit.entity.Player player)
      Opens the player’s current inventory again.
      Parameters:
      player - The player.
    • updateInventory

      void updateInventory(org.bukkit.entity.Player player, org.bukkit.plugin.Plugin plugin)
      Opens the player’s current inventory again if the plugin is the same.
      Parameters:
      player - The player.
      plugin - The plugin.
    • saveItem

      void saveItem(org.bukkit.command.CommandSender sender, org.bukkit.inventory.ItemStack itemStack, String name, String type)
      Save item in config file
      Parameters:
      sender - Command Sender
      itemStack - The itemStack
      name - The item name
      type -
    • loadClicks

      List<org.bukkit.event.inventory.ClickType> loadClicks(List<String> loadClicks)
      Transforms a string list into a click list type. If the list contains ANY or ALL then the ClickType present in the plugin configuration will be added to the list.
      Parameters:
      loadClicks - - Click type as string
      Returns:
      Loaded click type
    • registerItemStackVerification

      void registerItemStackVerification(fr.maxlego08.menu.api.itemstack.ItemStackSimilar itemStackSimilar)
      Registers an ItemStackSimilar instance for verifying ItemStacks. This method allows for adding a new ItemStack verification strategy to the system.
      Parameters:
      itemStackSimilar - The ItemStackSimilar instance to be registered.
    • getItemStackVerification

      Optional<fr.maxlego08.menu.api.itemstack.ItemStackSimilar> getItemStackVerification(String name)
      Retrieves an Optional ItemStackSimilar instance based on its name. This method is used to get a specific ItemStack verification strategy by its unique name. If no verification strategy is found with the given name, an empty Optional is returned.
      Parameters:
      name - The name of the ItemStack verification strategy to retrieve.
      Returns:
      An Optional containing the ItemStackSimilar instance if found, or an empty Optional otherwise.
    • getItemStackVerifications

      Collection<fr.maxlego08.menu.api.itemstack.ItemStackSimilar> getItemStackVerifications()
      Returns a collection of all registered ItemStackSimilar instances. This method is used to get all the available ItemStack verification strategies currently registered. The collection contains instances of ItemStackSimilar, each representing a different verification strategy.
      Returns:
      A Collection of ItemStackSimilar instances representing all registered verification strategies.
    • getScheduler

      ZScheduler getScheduler()
      Gets the scheduler associated with this button option.
      Returns:
      The ZScheduler associated with this button option.
    • registerOption

      void registerOption(org.bukkit.plugin.Plugin plugin, Class<? extends ButtonOption> buttonOption)
      Registers a new button option class with the plugin.
      Parameters:
      plugin - The plugin with which the button option is to be registered.
      buttonOption - The class of the button option to register.
    • unregisterOptions

      void unregisterOptions(org.bukkit.plugin.Plugin plugin)
      Unregisters all button options associated with the given plugin.
      Parameters:
      plugin - The plugin whose button options are to be unregistered.
    • getOptions

      Map<org.bukkit.plugin.Plugin,List<Class<? extends ButtonOption>>> getOptions()
      Retrieves a map of all registered button options grouped by plugin.
      Returns:
      A Map where each key is a Plugin and each value is a List of button option classes associated with that plugin.
    • getOption

      Optional<Class<? extends ButtonOption>> getOption(String name)
      Retrieves an Optional containing the class of the button option with the given name.
      Parameters:
      name - The name of the button option to retrieve.
      Returns:
      An Optional containing the button option class if found, or an empty Optional if not found.
    • setPlayerPage

      void setPlayerPage(org.bukkit.OfflinePlayer player, int page, int maxPage)
      Sets the current page number for a given player in a paginated context. This method is useful for managing player-specific UI elements that require pagination, such as inventory screens or custom GUIs. It allows for the tracking and updating of the player's current page within a multi-page UI component.
      Parameters:
      player - The OfflinePlayer instance representing the player whose page number is being set. This object allows for the operation to affect players who are not currently online as well.
      page - The current page number to set for the player. This should be within the range of 1 to maxPage, inclusive.
      maxPage - The maximum number of pages available. This is used to validate the page parameter and ensure it does not exceed the available range of pages.
    • getPage

      int getPage(org.bukkit.OfflinePlayer player)
      Retrieves the current page number of a given player in a paginated context. This method is typically used in conjunction with setPlayerPage(OfflinePlayer, int, int) to manage navigation through a multi-page UI component, allowing for a dynamic user experience based on the player's interaction.
      Parameters:
      player - The OfflinePlayer instance representing the player whose current page number is being queried. This enables the method to obtain information about players who are not currently online.
      Returns:
      The current page number of the specified player. If the player's page has not been set previously, this method may return a default value or 0, depending on implementation.
    • getMaxPage

      int getMaxPage(org.bukkit.OfflinePlayer player)
      Obtains the maximum page number set for a given player in a paginated context. This method allows for the retrieval of the upper limit of the pagination range for a player, facilitating UI boundary checks and preventing navigation beyond the available content.
      Parameters:
      player - The OfflinePlayer instance representing the player whose maximum page number is being retrieved. As with other methods, this supports offline players, allowing for a wide range of applications.
      Returns:
      The maximum page number available for the specified player. Similar to getPage(OfflinePlayer), if the max page has not been set, this method might return a default value or 0, depending on how it's implemented.
    • getFakeInventory

      fr.maxlego08.menu.inventory.inventories.InventoryDefault getFakeInventory()