IT
Features:
- Set amount
- Set DisplayName
- Set unbreakable Durability
- Set Lore
- Enable item glow
- Set skull owner
- Set color (banner, armor, wool)
- Add Enchantments
- Add item flat
- Set item meta
- Set durability
Todo:
- Implement your ideas
- Support users :D
Sourcecode:
public class ItemBuilder {
private ItemStack itemStack ;
private ItemMeta itemMeta ;
public ItemBuilder ( Material material, short subID ) {
itemStack = new ItemStack ( material, 1 , subID ) ;
itemMeta = itemStack. getItemMeta ( ) ;
}
public ItemBuilder ( Material material ) {
this ( material, ( short ) 0 ) ;
}
public ItemBuilder setAmount ( int amount ) {
itemStack. setAmount ( amount ) ;
return this ;
}
public ItemBuilder setName ( String name ) {
itemMeta. setDisplayName ( name ) ;
return this ;
}
public ItemBuilder setUnbreakable ( boolean state ) {
itemMeta. spigot ( ) . setUnbreakable ( state ) ;
return this ;
}
public ItemBuilder setLore ( String ... lore ) {
itemMeta. setLore ( Arrays . asList ( lore ) ) ;
return this ;
}
public ItemBuilder setLore ( List < String > lore ) {
itemMeta. setLore ( lore ) ;
return this ;
}
public ItemBuilder setGlow ( ) {
if ( itemMeta. getEnchants ( ) . isEmpty ( ) ) {
itemMeta. addItemFlags ( ItemFlag. HIDE_ENCHANTS ) ;
itemMeta. addEnchant ( Enchantment. OXYGEN , 0 , true ) ;
}
return this ;
}
public ItemBuilder setSkullOwner ( String skullOwner ) {
if ( itemStack. getType ( ) . equals ( Material. SKULL_ITEM ) ) {
SkullMeta skullMeta = ( ( SkullMeta ) itemMeta ) ;
skullMeta. setOwner ( skullOwner ) ;
}
return this ;
}
public ItemBuilder addEnchantment ( Enchantment enchantment, int level, boolean unsafe ) {
itemMeta. addEnchant ( enchantment, level, unsafe ) ;
return this ;
}
public ItemBuilder addEnchantments ( Map < Enchantment, Integer > enchantments, boolean unsafe ) {
for ( Enchantment current : enchantments. keySet ( ) )
itemMeta. addEnchant ( current, enchantments. get ( current ) , unsafe ) ;
return this ;
}
public ItemBuilder setBannerColor ( DyeColor color ) {
try {
BannerMeta bannerMeta = ( ( BannerMeta ) itemMeta ) ;
bannerMeta. setBaseColor ( color ) ;
} catch ( Exception exception ) {
System . out . println ( "Can't change banner color" + exception ) ;
}
return this ;
}
public ItemBuilder setWoolColor ( DyeColor color ) {
if ( itemStack. getType ( ) . equals ( Material. WOOL ) ) {
//replace this to color.getDyeData(); when you want to use 1a higher version
itemStack. setDurability ( color. getData ( ) ) ;
}
return this ;
}
public ItemBuilder setLeatherColor ( Color color ) {
try {
LeatherArmorMeta leatherArmorMeta = ( ( LeatherArmorMeta ) itemMeta ) ;
leatherArmorMeta. setColor ( color ) ;
} catch ( Exception exception ) {
System . out . println ( "Can't change leather color" + exception ) ;
}
return this ;
}
public ItemBuilder setDurability ( int durability ) {
itemStack. setDurability ( ( short ) durability ) ;
return this ;
}
public ItemBuilder addFlag ( ItemFlag itemFlag ) {
itemMeta. addItemFlags ( itemFlag ) ;
return this ;
}
public ItemBuilder setItemMeta ( ItemMeta itemMeta ) {
itemStack. setItemMeta ( itemMeta ) ;
return this ;
}
public ItemStack toItemStack ( ) {
itemStack. setItemMeta ( itemMeta ) ;
return itemStack ;
}
}Similar projects
Plugin →Let Me Despawn
Improves performance by tweaking mob despawn rules. Say bye to pesky unintentional persistent mobs.
25MSueta
JourneyMap
Real-time map used for mapping in-game or your browser as you explore.
14.7MSueta
Emotecraft
Create your own emotes in Minecraft.
7.5MSueta
Simple Tpa
A simple tpa plugin which sends requests
5.4MSueta
Common Network
Forge and Fabric Unified Networking Solution
3.9MSueta
Set Home
A lightweight plugin for players to set their homes.
3.8MSueta