ModsJava
Complex Inventories [API]
Java mod listed for Minecraft 1.8–1.13. Downloads from the MC Java Mods app on Android.
⬇ Download on Spigot
Source code can be found here.
Author: U8Y
Amazing plugin that is using this API: Redis Punish
Images of a simple example:
Spoiler: Images of a simple inventory created with this API
Manager
You would want to have a manager class that holds all inventories etc.
Spoiler: A simple getter instance of your plugin
/**
* Both {@link ComplexBase<T>} and {@link ComplexPage<T>}
* will depend on this particular class as this is their parent class.
*
* <T> type parameter is in this instance {@link Manager}
*/
public class Manager {
private JavaPlugin plugin ;
public Manager (JavaPlugin plugin ) {
this. plugin = plugin ;
}
public JavaPlugin getPlugin ( ) {
return plugin ;
}
}
Once you created a simple manager you can continue with actually making the inventories.
Code (Java):
/**
* Both {@link ComplexBase<T>} and {@link ComplexPage<T>}
* will depend on this particular class as this is their parent class.
*
* <T> type parameter is in this instance {@link Manager}
*/
public class Manager {
private JavaPlugin plugin ;
public Manager (JavaPlugin plugin ) {
this. plugin = plugin ;
}
public JavaPlugin getPlugin ( ) {
return plugin ;
}
}
Inventory Class (With and without animation)
This is the class where you will create your custom inventory.
Spoiler: Creating the Inventory
Spoiler: Without animated items
/**
* @param <T> {@link T} Is the same class where {@link ComplexBase<T>} will be created.
*/
public class TestInventory extends ComplexPage <Manager > {
public TestInventory (Manager manager, Player player ) {
super (manager, manager. getPlugin ( ), player, "Test Inventory", 54 ) ;
}
public void loadPage ( ) {
String item = "" + ChatColor. GREEN + ChatColor. BOLD + "Custom Item!" ;
String button = "" + ChatColor. GREEN + ChatColor. BOLD + "Custom button!" ;
String [ ] lore = {
ChatColor. GRAY + "This is your custom lore.",
ChatColor. GRAY + "You can add as many lines as you want!"
} ;
addItem ( 13, new Item (Material. BED, item, lore, 1 ) ) ;
addClick ( 15, new Item (Material. BOOK, button, lore, 1 ), new TestButton ( ) ) ;
}
private class TestButton implements ComplexButton {
public TestButton ( ) {
//Here, you can give any paramater you might want to use...
}
public void playerClick (Player player, ClickType clickType ) {
player. sendMessage ( "You just click on a button!" ) ;
player. closeInventory ( ) ;
}
}
}
Code (Java):
/**
* @param <T> {@link T} Is the same class where {@link ComplexBase<T>} will be created.
*/
public class TestInventory extends ComplexPage <Manager > {
public TestInventory (Manager manager, Player player ) {
super (manager, manager. getPlugin ( ), player, "Test Inventory", 54 ) ;
}
public void loadPage ( ) {
String item = "" + ChatColor. GREEN + ChatColor. BOLD + "Custom Item!" ;
String button = "" + ChatColor. GREEN + ChatColor. BOLD + "Custom button!" ;
String [ ] lore = {
ChatColor. GRAY + "This is your custom lore.",
ChatColor. GRAY + "You can add as many lines as you want!"
} ;
addItem ( 13, new Item (Material. BED, item, lore, 1 ) ) ;
addClick ( 15, new Item (Material. BOOK, button, lore, 1 ), new TestButton ( ) ) ;
}
private class TestButton implements ComplexButton {
public TestButton ( ) {
//Here, you can give any paramater you might want to use...
}
public void playerClick (Player player, ClickType clickType ) {
player. sendMessage ( "You just click on a button!" ) ;
player. closeInventory ( ) ;
}
}
}
Spoiler: With animated items
/**
* @param <T> {@link T} Is the same class where {@link ComplexBase<T>} will be created.
*/
public class TestInventory extends ComplexPage <Manager > {
public TestInventory (Manager manager, Player player ) {
super (manager, manager. getPlugin ( ), player, "Test Inventory", 54 ) ;
setInterval ( new Interval (1000ms ), this ) ; //Set update-interval here!
}
//Redstone Block Animation
private List <Item > items = new ArrayList <> ( ) ;
private int itemsIndex = 0 ;
public void loadAnimation ( )
{
items. add ( new Item (Material. DIAMOND, prefix + "Animated", new String [ ]
{
" ",
a + "- This is an animated item with a custom interval of 1000ms!",
l + "- Created by the ComplexInventories API",
l + "- Nothing else has been used to create this!",
" ",
C. cDGray + "Amazing for when u constantly need to update a player-count!"
}, 1 ) ) ;
items. add ( new Item (Material. BAKED_POTATO, C. cGreen + C. Bold + "Animated", new String [ ]
{
" ",
l + "- This is an animated item with a custom interval of 1000ms!",
l + "- Created by the ComplexInventories API",
a + "- Nothing else has been used to create this!",
" ",
C. cDGray + "Amazing for when u constantly need to update a player-count!"
}, 1 ) ) ;
}
public void loadPage ( ) {
addItem ( 13, items. get (itemsIndex ) ) ;
}
// NEW DON'T FORGET TO ADD EVENT
@EventHandler
public void update (InventoryUpdateEvent event )
{
if (event. getPage ( ) != this ) //Check whether it's this inventory
return ;
//Do any changes that you might want to do in here...
itemsIndex ++;
if (itemsIndex >= items. size ( ) )
itemsIndex = 0 ;
loadPage ( ) ;
}
}
Code (Java):
/**
* @param <T> {@link T} Is the same class where {@link ComplexBase<T>} will be created.
*/
public class TestInventory extends ComplexPage <Manager > {
public TestInventory (Manager manager, Player player ) {
super (manager, manager. getPlugin ( ), player, "Test Inventory", 54 ) ;
setInterval ( new Interval (1000ms ), this ) ; //Set update-interval here!
}
//Redstone Block Animation
private List <Item > items = new ArrayList <> ( ) ;
private int itemsIndex = 0 ;
public void loadAnimation ( )
{
items. add ( new Item (Material. DIAMOND, prefix + "Animated", new String [ ]
{
" ",
a + "- This is an animated item with a custom interval of 1000ms!",
l + "- Created by the ComplexInventories API",
l + "- Nothing else has been used to create this!",
" ",
C. cDGray + "Amazing for when u constantly need to update a player-count!"
}, 1 ) ) ;
items. add ( new Item (Material. BAKED_POTATO, C. cGreen + C. Bold + "Animated", new String [ ]
{
" ",
l + "- This is an animated item with a custom interval of 1000ms!",
l + "- Created by the ComplexInventories API",
a + "- Nothing else has been used to create this!",
" ",
C. cDGray + "Amazing for when u constantly need to update a player-count!"
}, 1 ) ) ;
}
public void loadPage ( ) {
addItem ( 13, items. get (itemsIndex ) ) ;
}
// NEW DON'T FORGET TO ADD EVENT
@EventHandler
public void update (InventoryUpdateEvent event )
{
if (event. getPage ( ) != this ) //Check whether it's this inventory
return ;
//Do any changes that you might want to do in here...
itemsIndex ++;
if (itemsIndex >= items. size ( ) )
itemsIndex = 0 ;
loadPage ( ) ;
}
}
Execution Method
Once you have your manager and your inventory class, obviously we would need a class that open this amazing looking inventory! Let's choose to open this inventory with a simple /test command
Spoiler: This is how your inventory opens
/**
* @param <T> {@link T} Is the same class where {@link ComplexPage<T>} will be created.
*/
public class TestCommand extends ComplexBase <Manager > implements CommandExecutor {
public TestCommand (Manager manager ) {
super (manager. getPlugin ( ), manager ) ;
}
@Override
public boolean onCommand (CommandSender sender, Command command, String label, String [ ] args ) {
Player player = (Player ) sender ;
TestInventory page = new TestInventory (getPlugin ( ), player ) ;
page. loadPage ( ) ; //Be sure to load all items before opening!
page. loadAnimation ( ) ; //If you have an animation, load it here!
openInventory (player, page ) ;
return true ;
}
}
Code (Java):
/**
* @param <T> {@link T} Is the same class where {@link ComplexPage<T>} will be created.
*/
public class TestCommand extends ComplexBase <Manager > implements CommandExecutor {
public TestCommand (Manager manager ) {
super (manager. getPlugin ( ), manager ) ;
}
@Override
public boolean onCommand (CommandSender sender, Command command, String label, String [ ] args ) {
Player player = (Player ) sender ;
TestInventory page = new TestInventory (getPlugin ( ), player ) ;
page. loadPage ( ) ; //Be sure to load all items before opening!
page. loadAnimation ( ) ; //If you have an animation, load it here!
openInventory (player, page ) ;
return true ;
}
}
Finalisation
If you have made your manager the ComplexBase, you can skip this step but if you did the same like me, creating a command to execute the openInventory(); do the following;
Spoiler: Finalising and declaring Inventory
Code (Java):
public
class Manager
{
private JavaPlugin plugin ;
public Manager (JavaPlugin plugin ) {
this. plugin = plugin ;
// Inside of here, you now want to implement the command:
plugin. getCommand ( "test" ). setExecutor ( new TestCommand ( this ) ) ;
}
public JavaPlugin getPlugin ( ) {
return plugin ;
}
}
private JavaPlugin plugin ;
public Manager (JavaPlugin plugin ) {
this. plugin = plugin ;
// Inside of here, you now want to implement the command:
plugin. getCommand ( "test" ). setExecutor ( new TestCommand ( this ) ) ;
}
public JavaPlugin getPlugin ( ) {
return plugin ;
}
}
ItemHead (New in 1.2)
the Item object for which you use to make items in your inventory, didn't let you create player skulls to put in your inventory, now u can!
Spoiler: ItemHead usage
/**
* @param <T> {@link T} Is the same class where {@link ComplexBase<T>} will be created.
*/
public class TestInventory extends ComplexPage <Manager > {
public TestInventory (Manager manager, Player player ) {
super (manager, player, "Test Inventory", 54 ) ;
}
public void createPage ( ) {
Item item = new ItemHead (getPlayer ( ). getName ( ), "My Head", new String [ ] {l + "You are currently viewing this page!" }, 1 ) ;
addItem ( 13, item ) ;
}
}
Code (Java):
/**
* @param <T> {@link T} Is the same class where {@link ComplexBase<T>} will be created.
*/
public class TestInventory extends ComplexPage <Manager > {
public TestInventory (Manager manager, Player player ) {
super (manager, player, "Test Inventory", 54 ) ;
}
public void createPage ( ) {
Item item = new ItemHead (getPlayer ( ). getName ( ), "My Head", new String [ ] {l + "You are currently viewing this page!" }, 1 ) ;
addItem ( 13, item ) ;
}
}
Main Class
Last but not least, you would want to create a Manager object to execute all lines inside of its constructor:
Spoiler: Main class: initializing Manager
Code (Java):
public
final
class Main
extends JavaPlugin
{
@Override
public void onEnable ( ) {
new Manager ( this ) ;
}
}
@Override
public void onEnable ( ) {
new Manager ( this ) ;
}
}
Quick facts
- Edition: Minecraft Java
- File type: .jar
- Minecraft versions listed: 1.8, 1.9, 1.10
- How to install: Install the matching mod loader (Forge, Fabric or NeoForge) for your Minecraft version. → Download the .jar. → Put it in the .minecraft/mods folder and launch that loader profile.
- Where to get it: Opens on Spigot — not every file is mirrored on our own servers.
Install steps are the general flow for this file type — How to install Minecraft Java mods & modpacks walks through it step by step.
Complex Inventories [API] is a free Minecraft Java mod. Compatible with Minecraft 1.8, 1.9, 1.10, 1.11 and newer. Downloaded 292 times (via Spigot). Download it and open it directly in the game.