Making a simple item

You will only need a couple of actions to create a simple item.

TailsLib uses data classes to interact with managers, listeners, and other plugins. To create an item we need to create data that will describe the item itself, namely its id for the manager and other components, the name that will be used for players, lore (AKA description) and material.

To create a custom item in TailsLib, you implement the CustomItem interface by defining the getItemData method, which returns a CustomItemData object describing the item. This object includes the item's ID, name, description, and material.

// MyItem.java

// package and imports...

public MyItem implements CustomItem {

    @Override
    public @NotNull CustomItemData getItemData() {
        return new CustomItemData("myitem", "My actual item name", 
        new SimpleBuilder().addDesc("My description"), Material.IRON_AXE);
    }

}

You can create your description without IDescBuilder with simple List. Use ArrayList<String> to create description without description builders or use null if you want nothing in lore.


Using List as description is cool but TailsLib will not color your text to white and it will be purple. Add &f to make it white, TailsLib will replace color codes to the actual color in-game.

We already know what an ID is, its name and material, but we don't know what a SimpleDescBuilder is. TailsLib uses the IDescBuilder class to create item descriptions. You can create your own. The SimpleDescBuilder is a great base class that offers basic functions for writing item descriptions.

Then we should register our item in main class.

// packages
// imports (etc...)

public MyPlugin extends JavaPlugin {

    @Override
    public void onEnable() {
        // other code
        
        // Getting the manager.
        CustomItemManager manager = CustomItemManager.getManager(); 
        manager.register(new MyItem()); // lets register our item.
    }

}

Thats all. Use /citem command to get your item.

Last updated