Package fr.maxlego08.menu.api
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 Summary
Modifier and TypeMethodDescriptionvoidcreateNewInventory(org.bukkit.command.CommandSender sender, String fileName, int inventorySize, String inventoryName) Creates a new inventory file.voiddeleteInventories(org.bukkit.plugin.Plugin plugin) Deletes all inventories loaded from a plugin.voiddeleteInventory(Inventory inventory) Deletes an inventory.booleandeleteInventory(String name) Deletes an inventory based on its name.getCurrentPlayerInventory(org.bukkit.entity.Player player) Gets the current open inventory of a player.fr.maxlego08.menu.inventory.inventories.InventoryDefaultGets the FastEvents.Returns a collection of all loaded inventories.getInventories(org.bukkit.plugin.Plugin plugin) Returns a collection of inventories loaded from a specific plugin.getInventory(String name) Returns an optional ofInventorybased on its name.getInventory(String pluginName, String name) Returns an optional ofInventorybased on its name and the plugin name.getInventory(org.bukkit.plugin.Plugin plugin, String name) Returns an optional ofInventorybased on its name and the plugin.Optional<fr.maxlego08.menu.api.itemstack.ItemStackSimilar>Retrieves an Optional ItemStackSimilar instance based on its name.Collection<fr.maxlego08.menu.api.itemstack.ItemStackSimilar>Returns a collection of all registered ItemStackSimilar instances.Returns a list of material loaders.getMaterialLoader(String key) Returns a material loader based on a key.intgetMaxPage(org.bukkit.OfflinePlayer player) Obtains the maximum page number set for a given player in a paginated context.getMeta()Sets item name and item meta using Spigot or Adventure API.Optional<Class<? extends ButtonOption>>Retrieves an Optional containing the class of the button option with the given name.Map<org.bukkit.plugin.Plugin,List<Class<? extends ButtonOption>>> Retrieves a map of all registered button options grouped by plugin.intgetPage(org.bukkit.OfflinePlayer player) Retrieves the current page number of a given player in a paginated context.Optional<org.bukkit.plugin.Plugin>getPluginIgnoreCase(String pluginName) Returns an optional of a plugin based on its name.Gets the scheduler associated with this button option.voidLoads buttons.List<org.bukkit.event.inventory.ClickType>loadClicks(List<String> loadClicks) Transforms a string list into a click list type.voidLoads inventories of the plugin.loadInventory(org.bukkit.plugin.Plugin plugin, File file) Loads an inventory from a file.loadInventory(org.bukkit.plugin.Plugin plugin, File file, Class<? extends Inventory> classz) Loads an inventory from a file.loadInventory(org.bukkit.plugin.Plugin plugin, String fileName) Loads an inventory from a file.loadInventory(org.bukkit.plugin.Plugin plugin, String fileName, Class<? extends Inventory> classz) Loads an inventory from a file.loadInventoryOrSaveResource(org.bukkit.plugin.Plugin plugin, String fileName) Loads an inventory.loadInventoryOrSaveResource(org.bukkit.plugin.Plugin plugin, String fileName, Class<? extends Inventory> classz) Loads an inventory.voidopenInventory(org.bukkit.entity.Player player, Inventory inventory) Opens an inventory for a player.voidopenInventory(org.bukkit.entity.Player player, Inventory inventory, int page) Opens an inventory for a player on a specific page.voidopenInventory(org.bukkit.entity.Player player, Inventory inventory, int page, Inventory... inventories) Opens an inventory for a player on a specific page with old inventories.voidopenInventory(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.voidopenInventory(org.bukkit.entity.Player player, String inventoryName) Opens an inventory based on its name.voidopenInventory(org.bukkit.entity.Player player, String pluginName, String inventoryName) Opens an inventory based on its name and the plugin name.voidopenInventory(org.bukkit.entity.Player player, org.bukkit.plugin.Plugin plugin, String inventoryName) Opens an inventory based on its name and the plugin.voidregisterFastEvent(org.bukkit.plugin.Plugin plugin, FastEvent fastEvent) Adds a FastEvent listener, which is faster than Bukkit events.voidregisterItemStackVerification(fr.maxlego08.menu.api.itemstack.ItemStackSimilar itemStackSimilar) Registers an ItemStackSimilar instance for verifying ItemStacks.booleanregisterMaterialLoader(MaterialLoader materialLoader) Registers a material loader.voidregisterOption(org.bukkit.plugin.Plugin plugin, Class<? extends ButtonOption> buttonOption) Registers a new button option class with the plugin.voidreloadInventory(Inventory inventory) Reloads the configuration of an inventory.voidsaveItem(org.bukkit.command.CommandSender sender, org.bukkit.inventory.ItemStack itemStack, String name, String type) Save item in config filevoidsendInventories(org.bukkit.command.CommandSender sender) Displays the list of available inventories.voidsetPlayerPage(org.bukkit.OfflinePlayer player, int page, int maxPage) Sets the current page number for a given player in a paginated context.voidunregisterListener(org.bukkit.plugin.Plugin plugin) Unregisters a FastEvent listener.voidunregisterOptions(org.bukkit.plugin.Plugin plugin) Unregisters all button options associated with the given plugin.voidupdateInventory(org.bukkit.entity.Player player) Opens the player’s current inventory again.voidupdateInventory(org.bukkit.entity.Player player, org.bukkit.plugin.Plugin plugin) Opens the player’s current inventory again if the plugin is the same.Methods inherited from interface fr.maxlego08.menu.zcore.utils.storage.Savable
load, save
-
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
Returns an optional ofInventorybased on its name.- Parameters:
name- Inventory name.- Returns:
- Optional of
Inventory.
-
getInventory
Returns an optional ofInventorybased on its name and the plugin.- Parameters:
plugin- The plugin where the inventory comes from.name- Inventory name.- Returns:
- Optional of
Inventory.
-
getInventory
Returns an optional ofInventorybased 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
Returns a collection of inventories loaded from a specific plugin.- Parameters:
plugin- The plugin.- Returns:
- Inventories.
-
deleteInventory
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.
-
loadButtons
void loadButtons()Loads buttons. TheButtonLoaderRegisterEventevent will be called, allowing you to add your own buttons using this event. -
loadInventories
void loadInventories()Loads inventories of the plugin. -
getMaterialLoader
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
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
Opens an inventory based on its name. Note that this method searches in all inventories; it is more appropriate to use the methodopenInventory(Player, Plugin, String).- Parameters:
player- Player who will open the inventory.inventoryName- Name of the inventory to be opened.
-
getPluginIgnoreCase
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.
-
getMeta
MetaUpdater getMeta()Sets item name and item meta using Spigot or Adventure API.- Returns:
- MetaUpdater.
-
getCurrentPlayerInventory
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.
-
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 SenderitemStack- The itemStackname- The item nametype-
-
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
-
getItemStackVerification
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
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
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- TheOfflinePlayerinstance 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 tomaxPage, inclusive.maxPage- The maximum number of pages available. This is used to validate thepageparameter 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 withsetPlayerPage(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- TheOfflinePlayerinstance 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- TheOfflinePlayerinstance 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()
-