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
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
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
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.
Similar projects
Plugin →Let Me Despawn
Improves performance by tweaking mob despawn rules. Say bye to pesky unintentional persistent mobs.
25MSueta
JourneyMap
Real-time map used for mapping in-game or your browser as you explore.
14.7MSueta
Emotecraft
Create your own emotes in Minecraft.
7.5MSueta
Simple Tpa
A simple tpa plugin which sends requests
5.4MSueta
Common Network
Forge and Fabric Unified Networking Solution
3.9MSueta
Set Home
A lightweight plugin for players to set their homes.
3.8MSueta