Refactor to remove abstraction.
This commit is contained in:
@@ -15,6 +15,8 @@ import engine.objects.Building;
|
|||||||
import engine.objects.Portal;
|
import engine.objects.Portal;
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -29,17 +31,18 @@ public class dbRunegateHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
ArrayList<Integer> gateList = new ArrayList<>();
|
ArrayList<Integer> gateList = new ArrayList<>();
|
||||||
|
|
||||||
prepareCallable("SELECT DISTINCT `sourceBuilding` FROM `static_runegate_portals`;");
|
try (Connection connection = DbManager.getConnection();
|
||||||
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT DISTINCT `sourceBuilding` FROM `static_runegate_portals`;")) {
|
||||||
|
|
||||||
try {
|
ResultSet rs = preparedStatement.executeQuery();
|
||||||
ResultSet rs = executeQuery();
|
|
||||||
while (rs.next()) {
|
while (rs.next())
|
||||||
gateList.add(rs.getInt("sourceBuilding"));
|
gateList.add(rs.getInt("sourceBuilding"));
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
} finally {
|
Logger.error(e);
|
||||||
closeCallable();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return gateList;
|
return gateList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,11 +51,12 @@ public class dbRunegateHandler extends dbHandlerBase {
|
|||||||
ArrayList<Portal> portalList = new ArrayList<>();
|
ArrayList<Portal> portalList = new ArrayList<>();
|
||||||
Building sourceBuilding = (Building) DbManager.getObject(Enum.GameObjectType.Building, gateUID);
|
Building sourceBuilding = (Building) DbManager.getObject(Enum.GameObjectType.Building, gateUID);
|
||||||
|
|
||||||
prepareCallable("SELECT * FROM `static_runegate_portals` WHERE `sourceBuilding` = ?;");
|
try (Connection connection = DbManager.getConnection();
|
||||||
setInt(1, gateUID);
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_runegate_portals` WHERE `sourceBuilding` = ?;")) {
|
||||||
|
|
||||||
try {
|
preparedStatement.setInt(1, gateUID);
|
||||||
ResultSet rs = executeQuery();
|
|
||||||
|
ResultSet rs = preparedStatement.executeQuery();
|
||||||
|
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
int targetBuildingID = rs.getInt("targetBuilding");
|
int targetBuildingID = rs.getInt("targetBuilding");
|
||||||
@@ -63,9 +67,7 @@ public class dbRunegateHandler extends dbHandlerBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
Logger.error("Exception while loading runegate portals: " + e);
|
Logger.error(e);
|
||||||
} finally {
|
|
||||||
closeCallable();
|
|
||||||
}
|
}
|
||||||
return portalList;
|
return portalList;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user