From cf2bf2dacf30d615aaf6ad10e3aa7622429f0898 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 20 Oct 2023 16:11:55 -0400 Subject: [PATCH] DBhandler created for templates --- src/engine/db/handlers/dbZoneHandler.java | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/engine/db/handlers/dbZoneHandler.java b/src/engine/db/handlers/dbZoneHandler.java index 64b5754f..ac948589 100644 --- a/src/engine/db/handlers/dbZoneHandler.java +++ b/src/engine/db/handlers/dbZoneHandler.java @@ -11,7 +11,9 @@ package engine.db.handlers; import engine.Enum; import engine.gameManager.DbManager; +import engine.gameManager.ZoneManager; import engine.objects.Zone; +import engine.objects.ZoneTemplate; import org.pmw.tinylog.Logger; import java.sql.Connection; @@ -66,6 +68,24 @@ public class dbZoneHandler extends dbHandlerBase { return zone; } + public void LOAD_ALL_ZONE_TEMPLATES() { + + try (Connection connection = DbManager.getConnection(); + PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_building_blueprint")) { + + ResultSet rs = preparedStatement.executeQuery(); + + while (rs.next()) { + ZoneTemplate zoneTemplate = new ZoneTemplate(rs); + ZoneManager._zone_templates.put(zoneTemplate.templateID, zoneTemplate); + } + + } catch (SQLException e) { + Logger.error(e); + } + + } + public boolean DELETE_ZONE(final Zone zone) { try (Connection connection = DbManager.getConnection();