Sueta
IN

InventoryPaged

1.2

Create paged inventories automatically and manage them

·Plugin

WELCOME TO THE INVENTORYPAGED'S SPIGOT POST. SELECT YOUR LANGUAGE TO LEARN HOW TO USE IT

[English]

What's InventoryPaged?
InventoryPaged is an automatic paged inventory generator. This plugin manage the quantity of pages of the inventory and make pages for this inventories. To make an inventory with this library (a Lib plugin, so, it helps other plugins to use the same library without implemeting the library on the plugins code) you'll need to do three things.

Register your plugin
When you enable your plugin, you need to get the API, but also, you need to create to register your plugin inside the API. For that, in your enable code, you need to do this:

IPApi invApi;
@Override
public void onEnable() {
    invApi = IPApi.getApi();
    invApi.registerPlugin(this);
}

Create an inventory
To create an inventory, you need three things: create the inventory, set the list of itemstacks and a hashmap with the custom itemstacks and their slots:

Create an inventory:

ItemStack la = new ItemStack(Material.ARROW);
ItemMeta imla = la.getItemMeta();
imla.setDisplayName("<< previous");
la.setItemMeta(imla);
ItemStack ra = new ItemStack(Material.ARROW);
ItemMeta imra = ra.getItemMeta();
imra.setDisplayName("next >>");
ra.setItemMeta(imra);
invApi.createInv(this, "Inv1", "Inventory Test", 5, 1, la, 45, ra, 53);

Here, we say the material of the arrows, it can't be null, cause if you need more pages, you need arrows to switch the pages. The command is:

createInv(plugin, configInvName, InvName, listRows, customRows, leftArrowIT, leftArrowSlot, rightArrowIT, rightArrowSlot);

plugin: plugin that is using the plugin, normally "this"
configInvName: Name that receive the inv on the plugins config, to difference it from the other invs.
InvName: Name of the inventory
ListRows: quantity of rows for the list of ItemStacks
CustomRows: quantity of rows to use for the custom items
leftArrowIT: ItemStack of the left arrow
leftArrowSlot: slot of the left arrow
rightArrowIT: ItemStack of the right arrow
rightArrowSlot: slot of the right arrow

Note: this plugin updates the content of the inventory, please, if you are going to make different inventories, use different names for this, not create the inventory on the same created inventory

Set the list
After creating the inventory, you need to set the list of items:

List<ItemStack> list = new ArrayList<ItemStack>();
for (String its:itemFile.getConfigurationSection("Items").getKeys(false)) {
    ItemStack it = itemFile.getItemStack("Items." + its + ".Item");
    list.add(it);
}
invApi.setList(this, "Inv1", list);

Set the custom items
To set the custom items, this plugin uses hashmaps to set the ItemStack and the slot:

HashMap<Integer, ItemStack> map = new HashMap<Integer, ItemStack>();
ItemStack i = new ItemStack(Material.BARRIER);
ItemMeta im = i.getItemMeta();
im.setDisplayName(ChatColor.RED + "This is a decorative item");
i.setItemMeta(im);
map.put(49, i);
invApi.setCustomItems(this, "Inv1", map);

Using InvInteract event
This plugin also comes with an event that comes with the next features:

getClickedInventory();
getOpenInventory();
getClick();
getClickedItem();
getPlayer();
getPlugin();
getInvConfigName();
getCurrentPage();
getSlot();

How to use it to verify that the inventory is yours?

if (e.getPlugin() == this)

When event is fired, the plugin sends the inventory's owner, the plugin who owns that inventory, but it's fired to all the plugins that have this event. To check that it's your inventory, getPlugin() will say the inventory's owner, so, you only need to check if the plugin is the same as your plugin.

Terms of Use

By obtaining this plugin (by any means) you agree to the following:
1. You will not sell, forward, send, or redistribute this plugin to anyone in any form for any reason
2. You will not decompile the plugin or in any way attempt to obtain a copy of the source code
3. You acknowledge and adhere to any terms currently defined in this section, regardless of any changes made. It is your sole responsibility to stay updated on these terms.
4. If you donate, you will not refund it.

Similar projects

Plugin →