Inventories
View the Inventory System for CIYFLib.
Our inventory system makes GUIs easy to create while allowing for being dynamic. Below is a simple example where we've tidied an action to one of our items:
Inventory inventory = null;
try {
inventory = new Inventory(InventoryType.HOPPER, "CIFY | Main Panel", JavaPlugin.getPlugin(CIFYLibPlugin.class));
inventory.setItem(0, new ItemBuilder(Material.EMERALD.name()).withName("&a&lSome Button").withLore("&7I can only be shift clicked..", "&7Try me!").getItem(), (player, action) -> {
if (action == ClickType.SHIFT_LEFT) {
player.closeInventory();
player.sendMessage(StringUtil.translate("&aWell done! &7You did it :)"));
} else {
player.sendMessage(StringUtil.translate("&cHey! &7Nice try attempting to &c" + action.name() + " &7this item.."));
}
});
inventory.addItem(new ItemBuilder(Material.DIAMOND.name()).getItem(), (player, action) -> player.sendMessage("Hi, you interacted with me using " + action.name() + "."));
} catch (InvalidInventoryException | InvalidMaterialException ex) {
ex.printStackTrace();
}
if (inventory != null) {
inventory.open(p);
}
This implements both our Item Builder system and our custom inventory api.
Last updated