From 34024c9fb48a940181cf014954d9dfad74153163 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 17 Oct 2023 08:45:33 -0400 Subject: [PATCH] New handlers created --- src/engine/db/handlers/dbCityHandler.java | 17 +++++++++++++++++ src/engine/db/handlers/dbMobHandler.java | 17 +++++++++++++++++ src/engine/db/handlers/dbNPCHandler.java | 17 +++++++++++++++++ src/engine/db/handlers/dbZoneHandler.java | 17 +++++++++++++++++ 4 files changed, 68 insertions(+) diff --git a/src/engine/db/handlers/dbCityHandler.java b/src/engine/db/handlers/dbCityHandler.java index bf3d9d98..bf3cd67b 100644 --- a/src/engine/db/handlers/dbCityHandler.java +++ b/src/engine/db/handlers/dbCityHandler.java @@ -96,6 +96,23 @@ public class dbCityHandler extends dbHandlerBase { return objectList; } + public ArrayList GET_ALL_CITIES() { + + ArrayList cityList = new ArrayList<>(); + + try (Connection connection = DbManager.getConnection(); + PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_city`.*, `object`.`parent` FROM `obj_city` INNER JOIN `object` ON `object`.`UID` = `obj_city`.`UID` ORDER BY `object`.`UID` ASC;")) { + + ResultSet rs = preparedStatement.executeQuery(); + cityList = getObjectsFromRs(rs, 100); + + } catch (SQLException e) { + Logger.error(e); + } + + return cityList; + } + public ArrayList GET_CITIES_BY_ZONE(final int objectUUID) { ArrayList cityList = new ArrayList<>(); diff --git a/src/engine/db/handlers/dbMobHandler.java b/src/engine/db/handlers/dbMobHandler.java index 862ac29f..4934b6ee 100644 --- a/src/engine/db/handlers/dbMobHandler.java +++ b/src/engine/db/handlers/dbMobHandler.java @@ -65,6 +65,23 @@ public class dbMobHandler extends dbHandlerBase { return mobile; } + public ArrayList GET_ALL_MOBS() { + + ArrayList mobileList = new ArrayList<>(); + + try (Connection connection = DbManager.getConnection(); + PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_mob`.*, `object`.`parent` FROM `object` INNER JOIN `obj_mob` ON `obj_mob`.`UID` = `object`.`UID` ORDER BY `object`.`UID` ASC;")) { + + ResultSet rs = preparedStatement.executeQuery(); + mobileList = getObjectsFromRs(rs, 1000); + + } catch (SQLException e) { + Logger.error(e); + } + + return mobileList; + } + public boolean updateUpgradeTime(Mob mob, DateTime upgradeDateTime) { try (Connection connection = DbManager.getConnection(); diff --git a/src/engine/db/handlers/dbNPCHandler.java b/src/engine/db/handlers/dbNPCHandler.java index 51b20246..f11576ec 100644 --- a/src/engine/db/handlers/dbNPCHandler.java +++ b/src/engine/db/handlers/dbNPCHandler.java @@ -94,6 +94,23 @@ public class dbNPCHandler extends dbHandlerBase { return row_count; } + public ArrayList GET_ALL_NPCS() { + + ArrayList npcList = new ArrayList<>(); + + try (Connection connection = DbManager.getConnection(); + PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_npc`.*, `object`.`parent` FROM `object` INNER JOIN `obj_npc` ON `obj_npc`.`UID` = `object`.`UID` ORDER BY `object`.`UID` ASC;")) { + + ResultSet rs = preparedStatement.executeQuery(); + npcList = getObjectsFromRs(rs, 1000); + + } catch (SQLException e) { + Logger.error(e); + } + + return npcList; + } + public ArrayList GET_ALL_NPCS_FOR_ZONE(Zone zone) { ArrayList npcList = new ArrayList<>(); diff --git a/src/engine/db/handlers/dbZoneHandler.java b/src/engine/db/handlers/dbZoneHandler.java index 9cceccaa..66b68e69 100644 --- a/src/engine/db/handlers/dbZoneHandler.java +++ b/src/engine/db/handlers/dbZoneHandler.java @@ -27,6 +27,23 @@ public class dbZoneHandler extends dbHandlerBase { this.localObjectType = Enum.GameObjectType.valueOf(this.localClass.getSimpleName()); } + public ArrayList GET_ALL_ZONES() { + + ArrayList zoneList = new ArrayList<>(); + + try (Connection connection = DbManager.getConnection(); + PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_zone`.*, `object`.`parent` FROM `object` INNER JOIN `obj_zone` ON `obj_zone`.`UID` = `object`.`UID` ORDER BY `object`.`UID` ASC;")) { + + ResultSet rs = preparedStatement.executeQuery(); + zoneList = getObjectsFromRs(rs, 2000); + + } catch (SQLException e) { + Logger.error(e); + } + + return zoneList; + } + public ArrayList GET_ALL_NODES(Zone zone) { ArrayList wsmList = new ArrayList<>(); wsmList.addAll(zone.getNodes());