Item Builder
View the Item Builder for CIYFLib.
Creating custom itemstacks can be a pain, especially when it involves a name, lore, enchantments, item flags and even NBT tags. Our item builder makes this an absolute breeze, and will certainly minimise development time with plugins.
How about giving players an enchanted sword, that has hidden enchantments with an NBT tag?
Easy! Like so..
@EventHandler
public void onJoin(PlayerJoinEvent e) {
Player player = e.getPlayer();
ItemBuilder itemBuilder = new ItemBuilder(Material.DIAMOND_SWORD)
.withName("&cLucky Sword")
.withLore("&7A powerful, strong sword.")
.withEnchant(Enchantment.KNOCKBACK, 1)
.withFlag(ItemFlag.HIDE_ENCHANTS)
.withData(0)
.withNBTString("sword-type", "strong");
// Add our custom item to the players inventory.
player.getInventory().addItem(itemBuilder.getItem());
}
Last updated