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.
public class MyItem implements CustomItem {
@Override
public @NotNull CustomItemData itemData() {
return new CustomItemData("myitem", "My actual item name",
new SimpleBuilder().addDesc("My description"), Material.IRON_AXE);
}
}
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.
public MyPlugin extends JavaPlugin {
@Override
public void onEnable() {
CustomItemManager.register(new MyItem()); // lets register our item.
}
}
Thats all. Use /citem
command to get your item.
Last updated
Was this helpful?