GUICustomItem

Page where you can find all you need to create a custom item using a default GUItem class

The first thing that you have to do is create a custom item object. To do that, you have to write something like this:

GUItem item = new GUICustomItem(Material.MATERIAL);

Now is time to set some customizations to the item that you have created. There are two ways to do that. The first is to set the values inside the object declaration, like this:

GUItem item = new GUICustomItem(Material.MATERIAL)
    .setName("§fDisplayName")
    .setAmount(1)
    .setLore("First line", "Second Line")
    .setType(1)
    .addEnchant(Enchantment.ENCH, 1 /* lvl */, true /* ignore limit */)
    .setEnchant(new ItemEnchant(Enchantment.ENCH, 1, true), 
        new ItemEnchant(Enchantment.ENCH, 2, false))
    .setFlag(ItemFlag.FLAG);

The second way to do that is to call the methods after having created the object. So, you have to do like above:

GUItem item = new GUICustomItem(Material.MATERIAL);
item.setName("§fDisplayName");
item.setAmount(1);
item.setLore("First line", "Second Line");
item.setType(1);
item.addEnchant(Enchantment.ENCH, 1, true);
item.setEnchant(new ItemEnchant(Enchantment.ENCH, 1, true), 
    new ItemEnchant(Enchantment.ENCH, 2, false));
item.setFlag(ItemFlag.FLAG);

Another interesting thing that you can do is converting the GUICustomItem object to an ItemStack object using the buildToItemStack(); method like this:

GUItem item = new GUICustomItem(Material.MATERIAL);
// Add customizations here ...
ItemStack itemStack = item.buildToItemStack();

Last updated

Was this helpful?