Browse Source

DBhandler created for templates

combat-2
MagicBot 1 year ago
parent
commit
cf2bf2dacf
  1. 20
      src/engine/db/handlers/dbZoneHandler.java

20
src/engine/db/handlers/dbZoneHandler.java

@ -11,7 +11,9 @@ package engine.db.handlers; @@ -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 { @@ -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();

Loading…
Cancel
Save