From 15635534b0b5cafcb1ee0358b08d5f2c81caba4f Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 19 Feb 2024 02:25:25 -0500 Subject: [PATCH] Type enum with back support --- src/engine/Enum.java | 45 +++++++++++++++++++++------- src/engine/objects/ItemTemplate.java | 3 +- 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/src/engine/Enum.java b/src/engine/Enum.java index 0e686549..f67df8aa 100644 --- a/src/engine/Enum.java +++ b/src/engine/Enum.java @@ -565,23 +565,50 @@ public class Enum { // Enum for ItemBase flags public enum ItemType { - DECORATION(0), + UNKNOWN(0), WEAPON(1), ARMOR(2), - HAIR(3), + BASE(3), GOLD(4), - RUNE(5), SCROLL(5), BOOK(6), - COMMANDROD(7), + WAND(7), POTION(8), - TEARS(8), KEY(9), - GUILDCHARTER(10), + CHARTER(10), + GUILDTREE(11), + SOUNDSOURCE(12), JEWELRY(13), + CONTAINER(14), + FOUNTAIN(15), + FOOD(16), + DRINKCONTAINER(17), + MAPMARKER(18), + DEED(19), + EMPLOYMENTCONTRACT(20), + PETTOTEM(21), + SLAVECOLLAR(22), + BLANKKEY(23), + WARRANT(24), + FURNITUREDEED(25), + TENT(26), + REAGENT(27), + DEVICE(28), + FORMULA(29), + BUCKET(30), + TREASURE(31), + RUNE(32), + OFFERING(33), + RESOURCE(34), + REALMCHARTER(35), + // old itembase support + DECORATION(0), + HAIR(3), + COMMANDROD(7), + TEARS(8), + GUILDCHARTER(10), WINE(16), ALEJUG(17), - DEED(19), CONTRACT(20), PET(21), FURNITURE(25), @@ -589,9 +616,7 @@ public class Enum { FARMABLE(27), WATERBUCKET(30), GIFT(31), - OFFERING(33), - RESOURCE(34), - REALMCHARTER(35); + ; private final static HashMap _typeLookup = new HashMap<>(); private final int _value; diff --git a/src/engine/objects/ItemTemplate.java b/src/engine/objects/ItemTemplate.java index 53ab973d..ab20b087 100644 --- a/src/engine/objects/ItemTemplate.java +++ b/src/engine/objects/ItemTemplate.java @@ -78,8 +78,7 @@ public class ItemTemplate { // Parsing an enum - // item_type = Enum.ItemType.valueOf((String) jsonObject.get("item_type")); - + item_type = Enum.ItemType.valueOf((String) jsonObject.get("item_type")); item_eq_slots_value = ((Long) jsonObject.get("item_eq_slots_value")).intValue(); item_eq_slots_type = (boolean) jsonObject.get("item_eq_slots_type");