Skip to content

yoonaxes/MinecraftInventoryAPI

Repository files navigation


MinecraftInventoryAPI

An open source Bukkit util for Inventory API. This API is used to facilitate the creation of interactive inventory.


Initial Setup

Initial setup to start using InventoryAPI.

Maven:
<repository>
    <id>yoonaxes-maven</id>
    <name>yoonaxes repository</name>
    <url>https://maven.yoonaxes.pl/</url>
</repository>

<dependency>
  <groupId>net.yoonaxes.minecraft</groupId>
  <artifactId>inventoryapi</artifactId>
  <version>1.0</version>
</dependency>
Gradle:
repositories {
    ...
    maven {
        name = 'yoonaxes-maven'
        url = 'https://maven.yoonaxes.pl/'
    }
}

dependencies {
    implementation 'net.yoonaxes.minecraft:inventoryapi:1.0'
}
Download:

· Download InventoryAPI-1.0.jar

· Download other release

Example usage

Example usage of InventoryAPI.

import net.yoonaxes.inventory.builders.ItemBuilder;
import net.yoonaxes.inventory.callback.WindowCloseCallback;
import net.yoonaxes.inventory.callback.WindowOpenCallback;
import net.yoonaxes.inventory.gui.MenuWindow;
import net.yoonaxes.inventory.gui.Rows;
import org.bukkit.Material;
import org.bukkit.entity.Player;

public class ExampleMenu extends MenuWindow {

    public static void openMenu(Player player) {
        // It's simple!
        new ExampleMenu(player).open(player);
    }

    public ExampleMenu(Player player) {
        super("&8{>} &7Menu &f" + player.getName() + " &8| &7MinecraftInventoryAPI", Rows.ONE);
        
        /* Window callbacks */
        this.withWindowCallback((WindowOpenCallback) (humanEntity, windowAction) -> {
            humanEntity.sendMessage("Menu opened.");
        });
        
        this.withWindowCallback((WindowCloseCallback) (humanEntity, windowAction) -> {
            humanEntity.sendMessage("Menu closed.");
        });
        
        this.createItems(); /* Make create items method */

        /* You can fill empty slots with glass, add more Window Callbacks, add more items etc...
         * Example to fill empty slots with glass:
         * - this.fillEmptySlots(new ItemBuilder(Material.BLACK_STAINED_GLASS_PANE).withName("&8#").build()); */
    }

    private void createItems() {
        /* Example for static items
         * For example you can use too:
         * this.withItem(slot, ItemStack); */
        this.withItem(new ItemBuilder(Material.DIAMOND_SWORD).withName("&cFighting").withLore("&7Always :)").build());
        this.withItem(new ItemBuilder(Material.WATER_BUCKET).withName("&bSwimming").withLore("&7If you can, swim :D").build());
        this.withItem(new ItemBuilder(Material.IRON_PICKAXE).withName("&eMinning").withLore("&7If you want you can minning :P").build());

        /* Example for item with action
         * For example you can use too:
         * - this.withItem(ItemStack, ItemClickCallback);
         * - this.withItem(slot, ItemStack, ItemClickCallback);
         * But here I'm using a separate method to add an action for the item */
        this.withItem(8, new ItemBuilder(Material.EMERALD)
                .withName("&aIt's awesome!")
                .withLore(
                        "&7Give star on Github.",
                        "&7Click to take a link."
                )
                .build()
        );
        
        /* Add action to item on 8 slot in inventory */
        this.withItemAction(8, (humanEntity, itemClickAction) -> {
            humanEntity.sendMessage("Github: https://github.com/yoonaxes");
            humanEntity.sendMessage("Project: https://github.com/yoonaxes/MinecraftInventoryAPI");
        });
    }
}
Result:


About

An open source Bukkit util for Inventory API. This API is used to facilitate the creation of interactive inventory.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages