diff --git a/src/engine/db/handlers/dbItemHandler.java b/src/engine/db/handlers/dbItemHandler.java index b83a14a9..d6d3773b 100644 --- a/src/engine/db/handlers/dbItemHandler.java +++ b/src/engine/db/handlers/dbItemHandler.java @@ -193,9 +193,26 @@ public class dbItemHandler extends dbHandlerBase { } catch (Exception e) { Logger.error(e); } - } + public void LOAD_TEMPLATE_MODTABLES() { + + try (Connection connection = DbManager.getConnection(); + PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_vendor_items`;"); + ResultSet rs = preparedStatement.executeQuery()) { + + while (rs.next()) { + int templateID = rs.getInt("templateID"); + int modTable = rs.getInt("modTable"); + ItemTemplate template = ItemTemplate.templates.get(templateID); + template.modTable = modTable; + } + + } catch (Exception e) { + Logger.error(e); + } + + } public Item GET_ITEM(final int itemUUID) { Item item; diff --git a/src/engine/net/client/msg/ManageNPCMsg.java b/src/engine/net/client/msg/ManageNPCMsg.java index 8f37770a..7d564759 100644 --- a/src/engine/net/client/msg/ManageNPCMsg.java +++ b/src/engine/net/client/msg/ManageNPCMsg.java @@ -422,7 +422,6 @@ public class ManageNPCMsg extends ClientNetMsg { writer.putInt(rollableSet.size()); for (int templateID : rollableSet) { - ItemBase item = ItemBase.getItemBase(templateID); ItemTemplate template = ItemTemplate.templates.get(templateID); writer.put((byte) 1); writer.putInt(0); @@ -430,10 +429,10 @@ public class ManageNPCMsg extends ClientNetMsg { writer.putInt(template.item_value); writer.putInt(600); writer.put((byte) 1); - writer.put((byte) item.getModTable()); - writer.put((byte) item.getModTable()); - writer.put((byte) item.getModTable()); - writer.put((byte) item.getModTable());//EffectItemType + writer.put((byte) template.modTable); + writer.put((byte) template.modTable); + writer.put((byte) template.modTable); + writer.put((byte) template.modTable);//EffectItemType } List itemList = npc.getRolling(); diff --git a/src/engine/objects/ItemFactory.java b/src/engine/objects/ItemFactory.java index c563c9bc..bb65abb3 100644 --- a/src/engine/objects/ItemFactory.java +++ b/src/engine/objects/ItemFactory.java @@ -640,7 +640,6 @@ public class ItemFactory { ModTableEntry prefixEntry = null; ModTableEntry suffixEntry = null; - ItemBase ib = ItemBase.getItemBase(templateID); ItemTemplate template = ItemTemplate.templates.get(templateID); if (template == null) @@ -654,7 +653,7 @@ public class ItemFactory { return null; } - itemModTable = (byte) ib.getModTable(); + itemModTable = (byte) template.modTable; if (!vendor.getItemModTable().contains(itemModTable)) { diff --git a/src/engine/objects/ItemTemplate.java b/src/engine/objects/ItemTemplate.java index 16c38e78..4c5e9de3 100644 --- a/src/engine/objects/ItemTemplate.java +++ b/src/engine/objects/ItemTemplate.java @@ -84,6 +84,7 @@ public class ItemTemplate { public static HashMap item_power_grant = new HashMap<>(); public HashMap item_power_action = new HashMap<>(); public HashMap item_resource_cost = new HashMap<>(); + public int modTable; // Deed related fields diff --git a/src/engine/server/login/LoginServer.java b/src/engine/server/login/LoginServer.java index 7b487426..b1ae150c 100644 --- a/src/engine/server/login/LoginServer.java +++ b/src/engine/server/login/LoginServer.java @@ -263,9 +263,6 @@ public class LoginServer { Logger.info("Initializing Blueprint data."); Blueprint.loadAllBlueprints(); - Logger.info("Loading Item Templates"); - DbManager.ItemQueries.LOAD_ITEM_TEMPLATES(); - Logger.info("Loading Kits"); DbManager.KitQueries.GET_ALL_KITS(); diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index a827eb88..c5a11ddb 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -343,6 +343,9 @@ public class WorldServer { Logger.info("Loading Item Templates"); DbManager.ItemQueries.LOAD_ITEM_TEMPLATES(); + Logger.info("Back fill template modTables"); + DbManager.ItemQueries.LOAD_TEMPLATE_MODTABLES(); + Logger.info("Loading ItemBases"); ItemBase.loadAllItemBases();