@@ -19,27 +19,93 @@ public ItemBuilder(SimplexModule<?> plugin) {
1919 this .plugin = plugin ;
2020 }
2121
22+ /**
23+ * Create a new singular ItemStack.
24+ * @param material The material for the item.
25+ * @return A new ItemStack from the provided material.
26+ */
2227 public ItemStack createNoBounds (Material material ) {
2328 return new ItemStack (material , 1 );
2429 }
2530
31+ /**
32+ * Create a new ItemStack.
33+ * @param material The material for the item.
34+ * @param amount The amount of items the stack should represent.
35+ * @return A new ItemStack from the provided material.
36+ */
37+ public ItemStack createNoBounds (Material material , int amount ) {
38+ return new ItemStack (material , amount );
39+ }
40+
41+ /**
42+ * Create a new singular ItemStack with the specified ItemMeta.
43+ * @param material The material for the item.
44+ * @param metaData The ItemMeta to use for the item.
45+ * @return A new ItemStack from the provided material with the specified ItemMeta.
46+ */
2647 public ItemStack createWithMeta (Material material , ItemMeta metaData ) {
2748 ItemStack stack = new ItemStack (material , 1 );
2849 stack .setItemMeta (metaData );
2950 return stack ;
3051 }
3152
32- public Worker itemBuilder (Material material ) {
53+ /**
54+ * Create a new ItemStack with the specified ItemMeta.
55+ * @param material The material for the item.
56+ * @param metaData The ItemMeta to use for the item.
57+ * @param amount The amount of items the stack should represent.
58+ * @return A new ItemStack from the provided material with the specified ItemMeta.
59+ */
60+ public ItemStack createWithMeta (Material material , ItemMeta metaData , int amount ) {
61+ ItemStack stack = new ItemStack (material , amount );
62+ stack .setItemMeta (metaData );
63+ return stack ;
64+ }
65+
66+ /**
67+ * Create a new ItemBuilder Worker
68+ * @param material The material for the item.
69+ * @return A new appendable ItemBuilder Worker instance based on the given Material.
70+ */
71+ public Worker newItem (Material material ) {
3372 return new Worker (new ItemStack (material , 1 ));
3473 }
3574
75+ /**
76+ * Create a new ItemBuilder Worker
77+ * @param material The material for the item.
78+ * @param amount The amount of items the stack should represent.
79+ * @return A new appendable ItemBuilder Worker instance based on the given Material.
80+ */
81+ public Worker newItem (Material material , int amount ) {
82+ return new Worker (new ItemStack (material , amount ));
83+ }
84+
85+ public Worker editItem (ItemStack stack ) {
86+ return new Worker (stack );
87+ }
88+
89+ /**
90+ * Create a new AttributeModifier for an ItemStack's ItemMeta.
91+ * @param name The name of the modifier.
92+ * @param amount The amount to add
93+ * @param scalar Whether or not it should add as a number or a magnitude.
94+ * @return A new AttributeModifier.
95+ */
3696 public AttributeModifier add (String name , double amount , boolean scalar ) {
3797 if (scalar ) {
3898 return new AttributeModifier (name , amount , AttributeModifier .Operation .ADD_SCALAR );
3999 }
40100 return new AttributeModifier (name , amount , AttributeModifier .Operation .ADD_NUMBER );
41101 }
42102
103+ /**
104+ * Create a new AttributeModifier for an ItemStack's ItemMeta.
105+ * @param name The name of the modifier
106+ * @param amount The amount to multiply by
107+ * @return A new AttributeModifier.
108+ */
43109 public AttributeModifier multiply (String name , double amount ) {
44110 return new AttributeModifier (name , amount , AttributeModifier .Operation .MULTIPLY_SCALAR_1 );
45111 }
@@ -48,41 +114,94 @@ protected final class Worker {
48114 private final ItemStack stack ;
49115 private final ItemMeta meta ;
50116
117+ /**
118+ * @param stack The item to work from.
119+ */
51120 public Worker (ItemStack stack ) {
52121 this .stack = stack ;
53122 this .meta = stack .getItemMeta ();
54123 }
55124
125+ /**
126+ * Adds lore to the item. New lines should be separate Strings.
127+ * @param lore The item lore to add.
128+ * @return An appendable worker instance.
129+ */
56130 public final Worker addLore (String ... lore ) {
57131 meta .setLore (Arrays .asList (lore ));
58132 stack .setItemMeta (meta );
59133 return this ;
60134 }
61135
136+ /**
137+ * Change the item's name
138+ * @param customName The new name of the item.
139+ * @return An appendable worker instance.
140+ */
62141 public final Worker setName (String customName ) {
63142 meta .setDisplayName (customName );
64143 stack .setItemMeta (meta );
65144 return this ;
66145 }
67146
147+ /**
148+ * Add an enchantment to the item
149+ * @param enchantment The enchantment to add
150+ * @param level The level of the enchantment. This is non-restrictive.
151+ * @return An appendable worker instance.
152+ */
68153 public final Worker addEnchant (Enchantment enchantment , int level ) {
69154 meta .addEnchant (enchantment , level , true );
70155 stack .setItemMeta (meta );
71156 return this ;
72157 }
73158
159+ /**
160+ * Add an attribute to the item.
161+ * @param attribute The attribute to add.
162+ * @param modifier The type of attribute modifier to use.
163+ * @return An appendable worker instance.
164+ */
74165 public final Worker addAttribute (Attribute attribute , AttributeModifier modifier ) {
75166 meta .addAttributeModifier (attribute , modifier );
76167 stack .setItemMeta (meta );
77168 return this ;
78169 }
79170
171+ /**
172+ * Add item flags to an item.
173+ * @param flags Any amount of ItemFlags to add to the item.
174+ * @return An appendable worker instance.
175+ */
80176 public final Worker addItemFlags (ItemFlag ... flags ) {
81177 meta .addItemFlags (flags );
82178 stack .setItemMeta (meta );
83179 return this ;
84180 }
85181
182+ /**
183+ * Set the amount of items this stack should represent.
184+ * @param amount The amount of items this stack should represent.
185+ * @return An appendable worker instance.
186+ */
187+ public final Worker setAmount (int amount ) {
188+ stack .setAmount (amount );
189+ return this ;
190+ }
191+
192+ public final Worker setType (Material material ) {
193+ stack .setType (material );
194+ return this ;
195+ }
196+
197+ public final Worker setUnbreakable (boolean unbreakable ) {
198+ meta .setUnbreakable (unbreakable );
199+ return this ;
200+ }
201+
202+ /**
203+ * @return The final item.
204+ */
86205 public final ItemStack get () {
87206 return stack ;
88207 }
0 commit comments