diff --git a/src/engine/db/handlers/dbItemHandler.java b/src/engine/db/handlers/dbItemHandler.java index 8e6ffd95..2367563c 100644 --- a/src/engine/db/handlers/dbItemHandler.java +++ b/src/engine/db/handlers/dbItemHandler.java @@ -15,6 +15,9 @@ import engine.gameManager.DbManager; import engine.objects.AbstractCharacter; import engine.objects.CharacterItemManager; import engine.objects.Item; +import engine.objects.ItemTemplate; +import org.json.simple.JSONObject; +import org.json.simple.parser.JSONParser; import org.pmw.tinylog.Logger; import java.sql.Connection; @@ -163,6 +166,28 @@ public class dbItemHandler extends dbHandlerBase { return itemList; } + public void LOAD_ITEM_TEMPLATES() { + + JSONParser jsonParser = new JSONParser(); + + try (Connection connection = DbManager.getConnection(); + PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `cache_data_items`;")) { + + ResultSet rs = preparedStatement.executeQuery(); + + while (rs.next()) { + + JSONObject jsonObject = (JSONObject) jsonParser.parse(rs.getString("template")); + ItemTemplate itemTemplate = new ItemTemplate(jsonObject); + ItemTemplate.itemTemplates.put(rs.getInt("id"), itemTemplate); + } + + } catch (Exception e) { + Logger.error(e); + } + + } + public Item GET_ITEM(final int itemUUID) { Item item;