add item stack value

This commit is contained in:
unurled 2024-09-28 18:27:40 +02:00
parent 7f326710b9
commit 54d1f7ba52
Signed by: unurled
GPG key ID: EFC5F5E709B47DDD

View file

@ -57,6 +57,8 @@ public class Item {
@NotNull private Integer customModelData;
@NotNull private Integer stackSize;
@NotNull private Rarity rarity;
@NotNull private ItemType type;
@ -74,6 +76,7 @@ public class Item {
this.description = "";
this.rarity = Rarity.COMMON;
this.customModelData = 0;
this.stackSize = 1;
this.abilities = List.of();
this.attributes = new EnumMap<>(Attribute.class);
this.enchantments = new HashMap<>();
@ -87,6 +90,7 @@ public class Item {
this.description = "";
this.rarity = Rarity.COMMON;
this.customModelData = 0;
this.stackSize = 1;
this.abilities = List.of();
this.attributes = new EnumMap<>(Attribute.class);
this.enchantments = new HashMap<>();
@ -208,6 +212,15 @@ public class Item {
this.customModelData = customModelData;
}
// TODO: implement check for stack size on item related events
public @NotNull Integer getStackSize() {
return stackSize;
}
public void setStackSize(@NotNull Integer stackSize) {
this.stackSize = stackSize;
}
@Nullable
public ItemStack toItemStack() {
ItemStack item = new ItemStack(material);
@ -244,6 +257,8 @@ public class Item {
+ description
+ "\", \"customModelData\": "
+ customModelData
+ ", \"stackSize\": "
+ stackSize
+ ", \"rarity\": \""
+ rarity
+ "\", \"type\": \""
@ -270,6 +285,7 @@ public class Item {
this.material = Material.valueOf((String) map.get("material"));
this.description = (String) map.get("description");
this.customModelData = ((Double) map.get("customModelData")).intValue();
this.stackSize = ((Double) map.get("stackSize")).intValue();
this.rarity = Rarity.valueOf((String) map.get("rarity"));
this.type = ItemType.valueOf((String) map.get("type"));