-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathitemBuilder.java
More file actions
52 lines (49 loc) · 1.58 KB
/
itemBuilder.java
File metadata and controls
52 lines (49 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package play.mcdev.tv.ultimatefeatues.util;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import play.mcdev.tv.ultimatefeatues.Main;
import java.util.Arrays;
public class ItemBuilder {
private ItemMeta itemMeta;
private ItemStack itemStack;
public ItemBuilder(Material material){
itemStack = new ItemStack(material);
itemMeta = itemStack.getItemMeta();
}
public ItemBuilder setDisplayName(String displayName){
itemMeta.setDisplayName(displayName);
return this;
}
public ItemBuilder setLocalizedName(String localizedName){
itemMeta.setLocalizedName(localizedName);
return this;
}
public ItemBuilder setLore(String... lore){
itemMeta.setLore(Arrays.asList(lore));
return this;
}
public ItemBuilder setGlow(){
itemMeta.addEnchant(Enchantment.ARROW_FIRE, 0, true);
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
return this;
}
public ItemBuilder addEnchantment(Enchantment enchantment, int level, boolean ignore){
itemMeta.addEnchant(enchantment, level, ignore);
return this;
}
public ItemBuilder setUnbreakable(){
itemMeta.setUnbreakable(true);
return this;
}
public ItemBuilder addItemFlag(ItemFlag... itemFlags){
itemMeta.addItemFlags(itemFlags);
return this;
}
public ItemStack build(){
itemStack.setItemMeta(itemMeta);
return itemStack;
}
}