Fixed ItemBuilder#setAmount not working when using a base ItemStack

This commit is contained in:
NichtStudioCode 2021-05-05 16:55:26 +02:00
parent dcdcba3fab
commit 7697707b21

@ -67,6 +67,7 @@ public class ItemBuilder implements Cloneable {
*/ */
public ItemBuilder(@NotNull ItemStack base) { public ItemBuilder(@NotNull ItemStack base) {
this.base = base.clone(); this.base = base.clone();
this.amount = base.getAmount();
} }
/** /**
@ -87,7 +88,13 @@ public class ItemBuilder implements Cloneable {
* @return The {@link ItemStack} * @return The {@link ItemStack}
*/ */
public ItemStack build() { public ItemStack build() {
ItemStack itemStack = (base != null) ? base : new ItemStack(material, amount); ItemStack itemStack;
if (base != null) {
itemStack = base;
itemStack.setAmount(amount);
} else {
itemStack = new ItemStack(material, amount);
}
ItemMeta itemMeta = itemStack.getItemMeta(); ItemMeta itemMeta = itemStack.getItemMeta();
if (itemMeta != null) { if (itemMeta != null) {