Skip to content

Tiny API for Spigot and Paper that helps you to build your ItemStack easier

Notifications You must be signed in to change notification settings

RusterX16/ItemBuilder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ItemBuilder

ItemBuilder is a tiny Java API for Paper and Spigot that help you to create ItemStack way much easier.
Thank you for reading this repository. You're free to use this class in your projet and contribute to it if you want to.

  • Creating ItemBuilder objects :

Instead of creating ItemStack like that :

ItemStack diamond = new ItemStack(Material.DIAMOND, 1);
ItemMeta meta = diamond.getItemMeta();
meta.displayName(Component.text("A Minecraft Diamond"));
meta.lore(List.of(Component.text("§bShining")));
item.setItemMeta(meta);

player.getInventory().add(diamond);

You will be able to create instances of ItemStack this way :

ItemStack diamond = new ItemBuilder(Material.DIAMOND, 1)
        .displayName("A Minecraft diamond")
        .lore("§bShining")
        .build();
        
player.getInventory().add(diamond);
  • Save your ItemBuilder instance :

Use the save() method to save the ItemBuilder instance to the memory if you want to edit one more time later :

ItemStack sword = new ItemBuilder(Material.IRON_SWORD)
        .addEnchantment(Enchantment.DAMAGE_ALL, 5)
        .hideFlags()
        .unbreakable(true)
        .save()
        .build();

Then, anywhere on your code, you will be able to get back the instance with the from(ItemStack) method :

ItemBuilder builder = ItemBuilder.from(sword);

Using save method isn't requiered if you're building an item that will never been updated in the futur.

About

Tiny API for Spigot and Paper that helps you to build your ItemStack easier

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages