Home›Java›Mods›InventoryAPI
InventoryAPI
ModsJava

InventoryAPI

Java mod listed for Minecraft 1.15. Downloads from the MC Java Mods app on Android.

⬇ Download on Spigot
Why does this plugin exist?
------------------------------------------------------------
For my own server, I have to create a lot of inventory GUIs. The problem is, that this is quite some work. That's why I made this InventoryAPI so it saves a lot of time and effort. For me, it saved more than 30% of the coding than I usually had to type.

What are the features?
------------------------------------------------------------
- Save about 30% of the lines of code.
- Make an inventory that automatically generates more pages. (Go to Step 2 for more information)
- Abillity to easily save an inventory to a file.

How does it work?
------------------------------------------------------------
Step 1: Create an InventoryGUI
Code (Java):
public InventoryGUI ( String title )
 
public InventoryGUI ( String title, int size )
 
public InventoryGUI ( UUID id, String title, int size )

public InventoryGUI ( UUID id, String title, int size, File saveFile )
 
public InventoryGUI ( UUID id, String title, int size, File saveFile, String savePath )
 
public InventoryGUI ( UUID id, String title, int size, File saveFile, boolean canCloseInventory )
 
public InventoryGUI ( UUID id, String title, int size, File saveFile, String savePath, boolean canCloseInventory )
- The id can just be a random UUID.
- These are all the methods you can use to create an InventoryGUI. For the size, use the actual size of the inventory(54 is the maximum).
- In case you don't want to use a saveFile, you can set this to null.


Step 2: Create InventoryItems
Code (Java):
public InventoryItem ( ItemStack item )
 
public InventoryItem ( ItemStack item, InventoryListener listener )
- You can use the InventoryAPI.buildItem function to easily build ItemStacks. If you wish, you can also just create
- If you leave the InventoryListener out, no listener will be added to the item. This means that the item can be taken from the inventory by a player.
- There are also some default listeners that you can use:
- InventoryListener.noEvent();
- InventoryListener.closeInventory();
- InventoryListener.sendMessage(String msg);
- InventoryListener.playSound(Sound sound, float volume, float pitch);
- Let's say, your inventory has a size of 9 slots and you put an item on the slot with the index 9. That will put that item on the second page on the slot with the index 0.

Example inventory
Code (Java):
inv. setItem ( 0 , new InventoryItem ( InventoryAPI. buildItem ( Material. STONE , 1 , "§6§lThis is a test item" , Arrays . asList ( "§7Test lore" ) ) ,
                new InventoryListener ( ) {
            @Override
            public void onClick ( InventoryClickEvent e ) {
                // Do something
            }
        } ) ) ;
   
        inv. openInventory ( p ) ;
If you've created some inventories, you might as well want to add some custom listeners. I made a couple:
- InventoryGUIBuildEvent
- PlayerClickInventoryGUIEvent
- PlayerCloseInventoryGUIEvent
- PlayerOpenInventoryGUIEvent
- PlayerSwitchInventoryGUIEvent

Feedback
------------------------------------------------------------
This is my first API so I'm very open for feedback. Feel free to use the discussions tab or send me a message on discord: Janderup#7857

Important notice: This is a beta version. It's not recommended yet to use this on big commercial servers.

Plugin details

Read from the plugin's own plugin.yml.

Quick facts

Install steps are the general flow for this file type — How to install Minecraft Java mods & modpacks walks through it step by step.

InventoryAPI is a free Minecraft Java mod. Compatible with Minecraft 1.15. Downloaded 187 times (via Spigot). Download it and open it directly in the game.

Explore more