diff --git a/src/engine/db/handlers/dbMineHandler.java b/src/engine/db/handlers/dbMineHandler.java index f00e900d..72b5befb 100644 --- a/src/engine/db/handlers/dbMineHandler.java +++ b/src/engine/db/handlers/dbMineHandler.java @@ -33,8 +33,24 @@ public class dbMineHandler extends dbHandlerBase { if (id == 0) return null; - Mine mine = (Mine) DbManager.getFromCache(Enum.GameObjectType.Mine, id); + try (Connection connection = DbManager.getConnection(); + PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM obj_mine;")) { + + //preparedStatement.setInt(1, id); + + ResultSet rs = preparedStatement.executeQuery(); + while(rs.next()){ + if(rs.getInt("UID") == id){ + int towerUID = rs.getInt("mine_buildingUID"); + mine = Mine.getMineFromTower(towerUID); + } + } + + + } catch (SQLException e) { + Logger.error(e); + } if (mine != null) return mine; diff --git a/src/engine/objects/Mine.java b/src/engine/objects/Mine.java index a6420bf9..c34b08d8 100644 --- a/src/engine/objects/Mine.java +++ b/src/engine/objects/Mine.java @@ -72,8 +72,8 @@ public class Mine extends AbstractGameObject { public Mine(ResultSet rs) throws SQLException, UnknownHostException { super(rs); - //this.mineType = MineProduction.getByName(rs.getString("mine_type")); - this.mineType = MineProduction.LUMBER; + this.mineType = MineProduction.getByName(rs.getString("mine_type")); + //this.mineType = MineProduction.LUMBER; int ownerUID = rs.getInt("mine_ownerUID"); this.buildingID = rs.getInt("mine_buildingUID"); @@ -282,7 +282,7 @@ public class Mine extends AbstractGameObject { for (Mine mine : serverMines) { Mine.mineMap.put(mine, mine.buildingID); Mine.towerMap.put(mine.buildingID, mine); - mine.mineType = MineProduction.LUMBER; + //mine.mineType = MineProduction.LUMBER; } try { diff --git a/src/engine/objects/MineProduction.java b/src/engine/objects/MineProduction.java index c5fdc9f5..a74e2fe7 100644 --- a/src/engine/objects/MineProduction.java +++ b/src/engine/objects/MineProduction.java @@ -36,33 +36,11 @@ public enum MineProduction { public static void addResources() { if (MineProduction.LUMBER.resources.size() == 0) { - // MineProduction.LUMBER.resources.put(7, Resource.GOLD); - // MineProduction.LUMBER.resources.put(1580004, Resource.LUMBER); - // MineProduction.LUMBER.resources.put(1580005, Resource.OAK); - // MineProduction.LUMBER.resources.put(1580006, Resource.BRONZEWOOD); - // MineProduction.LUMBER.resources.put(1580007, Resource.MANDRAKE); MineProduction.LUMBER.resources.put(7, Resource.GOLD); MineProduction.LUMBER.resources.put(1580004, Resource.LUMBER); MineProduction.LUMBER.resources.put(1580005, Resource.OAK); MineProduction.LUMBER.resources.put(1580006, Resource.BRONZEWOOD); MineProduction.LUMBER.resources.put(1580007, Resource.MANDRAKE); - MineProduction.LUMBER.resources.put(1580012, Resource.AZOTH); - MineProduction.LUMBER.resources.put(1580013, Resource.ORICHALK); - MineProduction.LUMBER.resources.put(1580014, Resource.ANTIMONY); - MineProduction.LUMBER.resources.put(1580015, Resource.SULFUR); - MineProduction.LUMBER.resources.put(1580016, Resource.QUICKSILVER); - MineProduction.LUMBER.resources.put(1580000, Resource.STONE); - MineProduction.LUMBER.resources.put(1580008, Resource.COAL); - MineProduction.LUMBER.resources.put(1580009, Resource.AGATE); - MineProduction.LUMBER.resources.put(1580010, Resource.DIAMOND); - MineProduction.LUMBER.resources.put(1580011, Resource.ONYX); - MineProduction.LUMBER.resources.put(1580001, Resource.TRUESTEEL); - MineProduction.LUMBER.resources.put(1580002, Resource.IRON); - MineProduction.LUMBER.resources.put(1580003, Resource.ADAMANT); - MineProduction.LUMBER.resources.put(1580018, Resource.WORMWOOD); - MineProduction.LUMBER.resources.put(1580020, Resource.BLOODSTONE); - MineProduction.LUMBER.resources.put(1580019, Resource.OBSIDIAN); - MineProduction.LUMBER.resources.put(1580017, Resource.GALVOR); } if (MineProduction.ORE.resources.size() == 0) { MineProduction.ORE.resources.put(7, Resource.GOLD);