
ComplexInventories does not need any pre-initialization therefore my onEnable() is also empty. You can use this api like this;
Source code can be found here.
Author: U8Y
Amazing plugin that is using this API: Redis Punish
Images of a simple example:
Images of a simple inventory created with this API

Manager
You would want to have a manager class that holds all inventories etc.
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.
Inventory Class (With and without animation)
This is the class where you will create your custom inventory.
Creating the Inventory
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();
}
}
}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();
}
}
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
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;
}
}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;
Finalising and declaring Inventory
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;
}
}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!
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);
}
}
Main Class
Last but not least, you would want to create a Manager object to execute all lines inside of its constructor:
Main class: initializing Manager
public final class Main extends JavaPlugin {
@Override
public void onEnable() {
new Manager(this);
}
}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