InventoryBuilder

Spigotでインベントリを簡単に作れるようにするビルダーです。

Features

  • Build pattern
  • Method Chaining
  • ItemStack builder
  • Easy to use

How to use

Install

Maven

<repositories>
	<repository>
	    <id>jitpack.io</id>
	    <url>https://jitpack.io</url>
	</repository>
</repositories>

<dependencies>
    <dependency>
        <groupId>com.github.tererun</groupId>
        <artifactId>InventoryBuilder</artifactId>
        <version>Tag</version>
    </dependency>
</dependencies>

Gradle

repositories {
    maven { url 'https://jitpack.io' }
}

dependencies {
    implementation 'com.github.tererun:InventoryBuilder:Tag'
}

Register InventoryBuilder

public class MainClass extends JavaPlugin {

    @Override
    public void onEnable() {
        Plugin plugin = this;
        
        InventoryBuilderProvider.register(plugin);
    }

}

Create new inventory

Plugin plugin = ...;

Inventory inventory = new InventoryBuilder("Inventory Title", 27)
    .addRow(new ItemRow("AAAAAAAAA"))
        .addRow(new ItemRow("AAASADAAA"))
        .addRow(new ItemRow("AAAAAAAAA"))
        .setItem('A', new InventoryItem(new ItemStack(Material.AIR)))
        .setItem('S', new ClickInventoryItem(new ItemStackBuilder(Material.STONE, 1)
                .setDisplayName("§aNormal Stone")
                .setLore("§oYou can get this stone")
                .build(),
                event -> {
                    event.getWhoClicked().sendMessage("This is stone!");
                }, false))
        .setItem('D', new ClickInventoryItem(new ItemStackBuilder(Material.DIAMOND, 1)
                .setDisplayName("§c§lFake Diamond")
                .setLore("§oDon't touch this")
                .build(),
                event -> {
                    Bukkit.getScheduler().runTask(plugin, () -> {
                        event.getWhoClicked().setHealth(0);
                    });
                }, true))
        .build(plugin);