InventoryPaged 1.2

Create paged inventories automatically and manage them

  1. relampagorojo93
    Tested Minecraft Versions:
    • 1.8
    • 1.9
    • 1.10
    • 1.11
    • 1.12
    WELCOME TO THE INVENTORYPAGED'S SPIGOT POST. SELECT YOUR LANGUAGE TO LEARN HOW TO USE IT

    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:
    Code (Text):
    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:

    Code (Text):
    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:

    Code (Text):
    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:

    Code (Text):
    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.

Recent Updates

  1. Custom arrow slot
  2. Added null detection

Recent Reviews

  1. Malacaritaa
    Malacaritaa
    5/5,
    Version: 1.0
    Awesome :o now its more easy make my own plugins :D!!
    ================================================
    100 letters: p