From 54d1f7ba52e75c36ce934cabf405310774b7f68e Mon Sep 17 00:00:00 2001 From: unurled Date: Sat, 28 Sep 2024 18:27:40 +0200 Subject: [PATCH] add item stack value --- .../sacredrealms/sr/components/item/Item.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main/java/me/unurled/sacredrealms/sr/components/item/Item.java b/src/main/java/me/unurled/sacredrealms/sr/components/item/Item.java index 9662781..c89732f 100644 --- a/src/main/java/me/unurled/sacredrealms/sr/components/item/Item.java +++ b/src/main/java/me/unurled/sacredrealms/sr/components/item/Item.java @@ -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"));