➠ Développeur(s) : BakaAless
➠ État : Fini
➠ API permettant de faciliter la création d'inventaires Minecraft. Cette API a été développée par et fait partie du projet Avatar-Returns.
➠ Créer un inventaire et le faire ouvrir par un joueur (remplacez JavaPlugin par votre classe principale):
final InventoryAPI inventory = InventoryAPI.create(JavaPlugin);
inventory.setSize(9);
inventory.setTitle("Mon premier inventaire");
inventory.build(player);
➠ Mettre un item dans l'inventaire sur un slot S, annuler le clic et envoyer un message au joueur :
final InventoryAPI inventory = InventoryAPI.create(JavaPlugin);
inventory.setSize(9);
inventory.setTitle("Mon premier inventaire");
inventory.addItem(S, itemstack, true, inventoryClickEvent -> {
player.sendMessage("Clic détecté");
});
inventory.build(player);
➠ Générer un item à partir d'une fonction et refresh l'inventaire tous les deux ticks :
final InventoryAPI inventory = InventoryAPI.create(JavaPlugin);
inventory.setSize(9);
inventory.setTitle("Mon premier inventaire");
inventory.setRefresh(true);
inventory.addItem(S, o -> {
final ItemStack itemStack = new ItemStack(Material.DIAMOND);
final ItemMeta itemMeta = itemStack.getItemMeta();
itemMeta.setDisplayName("§" + (new Random().nextInt(10)) + System.currentTimeMillis());
itemStack.setItemMeta(itemMeta);
return itemStack;
}, true, inventoryClickEvent -> {
player.sendMessage("Clic détecté");
});
inventory.build(player);
➠ La documentation Java est disponible ici.
➠ Pour intégrer ce code à gradle, en remplaçant Version
par la version ci-dessus :
repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
implementation group: 'com.github.BakaAless', name: 'InventoryAPI', version: 'VERSION'
}
InventoryAPI is under GPL-3.0 License.