|
|
@ -27,7 +27,6 @@ import java.time.LocalDateTime; |
|
|
|
import java.time.ZoneId; |
|
|
|
import java.time.ZoneId; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.concurrent.ConcurrentHashMap; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class dbBuildingHandler extends dbHandlerBase { |
|
|
|
public class dbBuildingHandler extends dbHandlerBase { |
|
|
|
|
|
|
|
|
|
|
@ -119,7 +118,7 @@ public class dbBuildingHandler extends dbHandlerBase { |
|
|
|
try (Connection connection = DbManager.getConnection(); |
|
|
|
try (Connection connection = DbManager.getConnection(); |
|
|
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_building`.*, `object`.`parent` FROM `object` INNER JOIN `obj_building` ON `obj_building`.`UID` = `object`.`UID` WHERE `object`.`UID` = ?;")) { |
|
|
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_building`.*, `object`.`parent` FROM `object` INNER JOIN `obj_building` ON `obj_building`.`UID` = `object`.`UID` WHERE `object`.`UID` = ?;")) { |
|
|
|
|
|
|
|
|
|
|
|
preparedStatement.setLong(1, (long) uuid); |
|
|
|
preparedStatement.setLong(1, uuid); |
|
|
|
|
|
|
|
|
|
|
|
ResultSet rs = preparedStatement.executeQuery(); |
|
|
|
ResultSet rs = preparedStatement.executeQuery(); |
|
|
|
building = (Building) getObjectFromRs(rs); |
|
|
|
building = (Building) getObjectFromRs(rs); |
|
|
@ -468,59 +467,55 @@ public class dbBuildingHandler extends dbHandlerBase { |
|
|
|
if (building == null) |
|
|
|
if (building == null) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
prepareCallable("SELECT * FROM `dyn_building_condemned` WHERE `buildingUID` = ?"); |
|
|
|
try (Connection connection = DbManager.getConnection(); |
|
|
|
setInt(1,building.getObjectUUID()); |
|
|
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_building_condemned` WHERE `buildingUID` = ?")) { |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
preparedStatement.setInt(1, building.getObjectUUID()); |
|
|
|
ResultSet rs = executeQuery(); |
|
|
|
ResultSet rs = preparedStatement.executeQuery(); |
|
|
|
|
|
|
|
|
|
|
|
//shrines cached in rs for easy cache on creation.
|
|
|
|
|
|
|
|
while (rs.next()) { |
|
|
|
while (rs.next()) { |
|
|
|
Condemned condemn = new Condemned(rs); |
|
|
|
Condemned condemned = new Condemned(rs); |
|
|
|
switch(condemn.getFriendType()){ |
|
|
|
switch (condemned.getFriendType()) { |
|
|
|
case 2: |
|
|
|
case 2: |
|
|
|
building.getCondemned().put(condemn.getPlayerUID(), condemn); |
|
|
|
building.getCondemned().put(condemned.getPlayerUID(), condemned); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 4: |
|
|
|
case 4: |
|
|
|
case 5: |
|
|
|
case 5: |
|
|
|
building.getCondemned().put(condemn.getGuildUID(), condemn); |
|
|
|
building.getCondemned().put(condemned.getGuildUID(), condemned); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} catch (SQLException e) { |
|
|
|
} catch (SQLException e) { |
|
|
|
Logger.error("LOAD Condemned for building: " + e.getErrorCode() + ' ' + e.getMessage(), e); |
|
|
|
Logger.error(e); |
|
|
|
} finally { |
|
|
|
|
|
|
|
closeCallable(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public ArrayList<Vector3fImmutable> LOAD_PATROL_POINTS(Building building) { |
|
|
|
public ArrayList<Vector3fImmutable> LOAD_PATROL_POINTS(Building building) { |
|
|
|
|
|
|
|
|
|
|
|
if (building == null) |
|
|
|
if (building == null) |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
|
|
|
|
|
|
|
|
ArrayList<Vector3fImmutable> patrolPoints = new ArrayList<>(); |
|
|
|
ArrayList<Vector3fImmutable> patrolPoints = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try (Connection connection = DbManager.getConnection(); |
|
|
|
|
|
|
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_building_patrol_points` WHERE `buildingUID` = ?")) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
preparedStatement.setInt(1, building.getObjectUUID()); |
|
|
|
|
|
|
|
|
|
|
|
prepareCallable("SELECT * FROM `dyn_building_patrol_points` WHERE `buildingUID` = ?"); |
|
|
|
|
|
|
|
setInt(1,building.getObjectUUID()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
ResultSet rs = preparedStatement.executeQuery(); |
|
|
|
ResultSet rs = executeQuery(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//shrines cached in rs for easy cache on creation.
|
|
|
|
|
|
|
|
while (rs.next()) { |
|
|
|
while (rs.next()) { |
|
|
|
float x1 = rs.getFloat("patrolX"); |
|
|
|
float x1 = rs.getFloat("patrolX"); |
|
|
|
float y1 = rs.getFloat("patrolY"); |
|
|
|
float y1 = rs.getFloat("patrolY"); |
|
|
|
float z1 = rs.getFloat("patrolZ"); |
|
|
|
float z1 = rs.getFloat("patrolZ"); |
|
|
|
Vector3fImmutable patrolPoint = new Vector3fImmutable(x1,y1,z1); |
|
|
|
Vector3fImmutable patrolPoint = new Vector3fImmutable(x1, y1, z1); |
|
|
|
patrolPoints.add(patrolPoint); |
|
|
|
patrolPoints.add(patrolPoint); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} catch (SQLException e) { |
|
|
|
} catch (SQLException e) { |
|
|
|
Logger.error("LOAD Patrol Points for building: " + e.getErrorCode() + ' ' + e.getMessage(), e); |
|
|
|
Logger.error(e); |
|
|
|
} finally { |
|
|
|
|
|
|
|
closeCallable(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return patrolPoints; |
|
|
|
return patrolPoints; |
|
|
@ -528,134 +523,136 @@ public class dbBuildingHandler extends dbHandlerBase { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public boolean ADD_TO_CONDEMNLIST(final long parentUID, final long playerUID, final long guildID, final int friendType) { |
|
|
|
public boolean ADD_TO_CONDEMNLIST(final long parentUID, final long playerUID, final long guildID, final int friendType) { |
|
|
|
prepareCallable("INSERT INTO `dyn_building_condemned` (`buildingUID`, `playerUID`,`guildUID`, `friendType`) VALUES (?,?,?,?)"); |
|
|
|
|
|
|
|
setLong(1, parentUID); |
|
|
|
try (Connection connection = DbManager.getConnection(); |
|
|
|
setLong(2, playerUID); |
|
|
|
PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_building_condemned` (`buildingUID`, `playerUID`,`guildUID`, `friendType`) VALUES (?,?,?,?)")) { |
|
|
|
setLong(3, guildID); |
|
|
|
|
|
|
|
setInt(4, friendType); |
|
|
|
preparedStatement.setLong(1, parentUID); |
|
|
|
return (executeUpdate() > 0); |
|
|
|
preparedStatement.setLong(2, playerUID); |
|
|
|
|
|
|
|
preparedStatement.setLong(3, guildID); |
|
|
|
|
|
|
|
preparedStatement.setInt(4, friendType); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (preparedStatement.executeUpdate() > 0); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (SQLException e) { |
|
|
|
|
|
|
|
Logger.error(e); |
|
|
|
|
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public boolean ADD_TO_PATROL(final long parentUID, final Vector3fImmutable patrolPoint) { |
|
|
|
|
|
|
|
prepareCallable("INSERT INTO `dyn_building_patrol_points` (`buildingUID`, `patrolX`,`patrolY`, `patrolZ`) VALUES (?,?,?,?)"); |
|
|
|
|
|
|
|
setLong(1, parentUID); |
|
|
|
|
|
|
|
setFloat(2, (int)patrolPoint.x); |
|
|
|
|
|
|
|
setFloat(3, (int)patrolPoint.y); |
|
|
|
|
|
|
|
setFloat(4, (int)patrolPoint.z); |
|
|
|
|
|
|
|
return (executeUpdate() > 0); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public HashMap<Integer, ArrayList<BuildingRegions>> LOAD_BUILDING_REGIONS() { |
|
|
|
public boolean ADD_TO_PATROL(final long parentUID, final Vector3fImmutable patrolPoint) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try (Connection connection = DbManager.getConnection(); |
|
|
|
|
|
|
|
PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_building_patrol_points` (`buildingUID`, `patrolX`,`patrolY`, `patrolZ`) VALUES (?,?,?,?)")) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
preparedStatement.setLong(1, parentUID); |
|
|
|
|
|
|
|
preparedStatement.setFloat(2, (int) patrolPoint.x); |
|
|
|
|
|
|
|
preparedStatement.setFloat(3, (int) patrolPoint.y); |
|
|
|
|
|
|
|
preparedStatement.setFloat(4, (int) patrolPoint.z); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (preparedStatement.executeUpdate() > 0); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (SQLException e) { |
|
|
|
|
|
|
|
Logger.error(e); |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
HashMap<Integer, ArrayList<BuildingRegions>> regions; |
|
|
|
} |
|
|
|
BuildingRegions thisRegions; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public HashMap<Integer, ArrayList<BuildingRegions>> LOAD_BUILDING_REGIONS() { |
|
|
|
|
|
|
|
|
|
|
|
regions = new HashMap<>(); |
|
|
|
HashMap<Integer, ArrayList<BuildingRegions>> regionList = new HashMap<>(); |
|
|
|
|
|
|
|
BuildingRegions buildingRegions; |
|
|
|
int recordsRead = 0; |
|
|
|
int recordsRead = 0; |
|
|
|
|
|
|
|
|
|
|
|
prepareCallable("SELECT * FROM static_building_regions"); |
|
|
|
try (Connection connection = DbManager.getConnection(); |
|
|
|
|
|
|
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_building_regions")) { |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
ResultSet rs = preparedStatement.executeQuery(); |
|
|
|
ResultSet rs = executeQuery(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (rs.next()) { |
|
|
|
while (rs.next()) { |
|
|
|
|
|
|
|
|
|
|
|
recordsRead++; |
|
|
|
recordsRead++; |
|
|
|
thisRegions = new BuildingRegions(rs); |
|
|
|
buildingRegions = new BuildingRegions(rs); |
|
|
|
if (regions.get(thisRegions.getBuildingID()) == null){ |
|
|
|
|
|
|
|
|
|
|
|
if (regionList.get(buildingRegions.getBuildingID()) == null) { |
|
|
|
ArrayList<BuildingRegions> regionsList = new ArrayList<>(); |
|
|
|
ArrayList<BuildingRegions> regionsList = new ArrayList<>(); |
|
|
|
regionsList.add(thisRegions); |
|
|
|
regionsList.add(buildingRegions); |
|
|
|
regions.put(thisRegions.getBuildingID(), regionsList); |
|
|
|
regionList.put(buildingRegions.getBuildingID(), regionsList); |
|
|
|
} |
|
|
|
} else { |
|
|
|
else{ |
|
|
|
ArrayList<BuildingRegions> regionsList = regionList.get(buildingRegions.getBuildingID()); |
|
|
|
ArrayList<BuildingRegions>regionsList = regions.get(thisRegions.getBuildingID()); |
|
|
|
regionsList.add(buildingRegions); |
|
|
|
regionsList.add(thisRegions); |
|
|
|
regionList.put(buildingRegions.getBuildingID(), regionsList); |
|
|
|
regions.put(thisRegions.getBuildingID(), regionsList); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Logger.info( "read: " + recordsRead + " cached: " + regions.size()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (SQLException e) { |
|
|
|
} catch (SQLException e) { |
|
|
|
Logger.error(": " + e.getErrorCode() + ' ' + e.getMessage(), e); |
|
|
|
Logger.error(e); |
|
|
|
} finally { |
|
|
|
return null; |
|
|
|
closeCallable(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return regions; |
|
|
|
|
|
|
|
|
|
|
|
Logger.info("read: " + recordsRead + " cached: " + regionList.size()); |
|
|
|
|
|
|
|
return regionList; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public HashMap<Integer, MeshBounds> LOAD_MESH_BOUNDS() { |
|
|
|
public HashMap<Integer, MeshBounds> LOAD_MESH_BOUNDS() { |
|
|
|
|
|
|
|
|
|
|
|
HashMap<Integer, MeshBounds> meshBoundsMap; |
|
|
|
HashMap<Integer, MeshBounds> meshBoundsMap = new HashMap<>(); |
|
|
|
MeshBounds meshBounds; |
|
|
|
MeshBounds meshBounds; |
|
|
|
|
|
|
|
|
|
|
|
meshBoundsMap = new HashMap<>(); |
|
|
|
|
|
|
|
int recordsRead = 0; |
|
|
|
int recordsRead = 0; |
|
|
|
|
|
|
|
|
|
|
|
prepareCallable("SELECT * FROM static_mesh_bounds"); |
|
|
|
try (Connection connection = DbManager.getConnection(); |
|
|
|
|
|
|
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_mesh_bounds")) { |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
ResultSet rs = preparedStatement.executeQuery(); |
|
|
|
ResultSet rs = executeQuery(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (rs.next()) { |
|
|
|
while (rs.next()) { |
|
|
|
|
|
|
|
|
|
|
|
recordsRead++; |
|
|
|
recordsRead++; |
|
|
|
meshBounds = new MeshBounds(rs); |
|
|
|
meshBounds = new MeshBounds(rs); |
|
|
|
|
|
|
|
|
|
|
|
meshBoundsMap.put(meshBounds.meshID, meshBounds); |
|
|
|
meshBoundsMap.put(meshBounds.meshID, meshBounds); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Logger.info( "read: " + recordsRead + " cached: " + meshBoundsMap.size()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (SQLException e) { |
|
|
|
} catch (SQLException e) { |
|
|
|
Logger.error("LoadMeshBounds: " + e.getErrorCode() + ' ' + e.getMessage(), e); |
|
|
|
Logger.error(e); |
|
|
|
} finally { |
|
|
|
|
|
|
|
closeCallable(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Logger.info("read: " + recordsRead + " cached: " + meshBoundsMap.size()); |
|
|
|
return meshBoundsMap; |
|
|
|
return meshBoundsMap; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public HashMap<Integer, ArrayList<StaticColliders>> LOAD_ALL_STATIC_COLLIDERS() { |
|
|
|
public HashMap<Integer, ArrayList<StaticColliders>> LOAD_ALL_STATIC_COLLIDERS() { |
|
|
|
|
|
|
|
|
|
|
|
HashMap<Integer, ArrayList<StaticColliders>> colliders; |
|
|
|
HashMap<Integer, ArrayList<StaticColliders>> colliders = new HashMap<>(); |
|
|
|
StaticColliders thisColliders; |
|
|
|
StaticColliders thisColliders; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
colliders = new HashMap<>(); |
|
|
|
|
|
|
|
int recordsRead = 0; |
|
|
|
int recordsRead = 0; |
|
|
|
|
|
|
|
|
|
|
|
prepareCallable("SELECT * FROM static_building_colliders"); |
|
|
|
try (Connection connection = DbManager.getConnection(); |
|
|
|
|
|
|
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_building_colliders")) { |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
ResultSet rs = preparedStatement.executeQuery(); |
|
|
|
ResultSet rs = executeQuery(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (rs.next()) { |
|
|
|
while (rs.next()) { |
|
|
|
|
|
|
|
|
|
|
|
recordsRead++; |
|
|
|
recordsRead++; |
|
|
|
thisColliders = new StaticColliders(rs); |
|
|
|
thisColliders = new StaticColliders(rs); |
|
|
|
if (colliders.get(thisColliders.getMeshID()) == null){ |
|
|
|
|
|
|
|
|
|
|
|
if (colliders.get(thisColliders.getMeshID()) == null) { |
|
|
|
ArrayList<StaticColliders> colliderList = new ArrayList<>(); |
|
|
|
ArrayList<StaticColliders> colliderList = new ArrayList<>(); |
|
|
|
colliderList.add(thisColliders); |
|
|
|
colliderList.add(thisColliders); |
|
|
|
colliders.put(thisColliders.getMeshID(), colliderList); |
|
|
|
colliders.put(thisColliders.getMeshID(), colliderList); |
|
|
|
} |
|
|
|
} else { |
|
|
|
else{ |
|
|
|
ArrayList<StaticColliders> colliderList = colliders.get(thisColliders.getMeshID()); |
|
|
|
ArrayList<StaticColliders>colliderList = colliders.get(thisColliders.getMeshID()); |
|
|
|
|
|
|
|
colliderList.add(thisColliders); |
|
|
|
colliderList.add(thisColliders); |
|
|
|
colliders.put(thisColliders.getMeshID(), colliderList); |
|
|
|
colliders.put(thisColliders.getMeshID(), colliderList); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Logger.info( "read: " + recordsRead + " cached: " + colliders.size()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (SQLException e) { |
|
|
|
} catch (SQLException e) { |
|
|
|
Logger.error("LoadAllBlueprints: " + e.getErrorCode() + ' ' + e.getMessage(), e); |
|
|
|
Logger.error(e); |
|
|
|
} finally { |
|
|
|
|
|
|
|
closeCallable(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Logger.info("read: " + recordsRead + " cached: " + colliders.size()); |
|
|
|
return colliders; |
|
|
|
return colliders; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -666,174 +663,204 @@ public class dbBuildingHandler extends dbHandlerBase { |
|
|
|
public final DbObjectType GET_UID_ENUM(long object_UID) { |
|
|
|
public final DbObjectType GET_UID_ENUM(long object_UID) { |
|
|
|
|
|
|
|
|
|
|
|
DbObjectType storedEnum = DbObjectType.INVALID; |
|
|
|
DbObjectType storedEnum = DbObjectType.INVALID; |
|
|
|
String typeString; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (object_UID == 0) |
|
|
|
if (object_UID == 0) |
|
|
|
return storedEnum; |
|
|
|
return storedEnum; |
|
|
|
|
|
|
|
|
|
|
|
// Set up call to stored procedure
|
|
|
|
try (Connection connection = DbManager.getConnection(); |
|
|
|
prepareCallable("CALL object_UID_ENUM(?)"); |
|
|
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `type` FROM `object` WHERE `object`.`UID` = n LIMIT 1;")) { |
|
|
|
setLong(1, object_UID); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
preparedStatement.setLong(1, object_UID); |
|
|
|
|
|
|
|
|
|
|
|
// Evaluate database ordinal and return enum
|
|
|
|
ResultSet rs = preparedStatement.executeQuery(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (rs.next()) |
|
|
|
storedEnum = DbObjectType.valueOf(getString("type").toUpperCase()); |
|
|
|
storedEnum = DbObjectType.valueOf(getString("type").toUpperCase()); |
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
} catch (SQLException e) { |
|
|
|
storedEnum = DbObjectType.INVALID; |
|
|
|
Logger.error("Building", e); |
|
|
|
Logger.error("UID_ENUM ", "Orphaned Object? Lookup failed for UID: " + object_UID); |
|
|
|
return DbObjectType.INVALID; |
|
|
|
} finally { |
|
|
|
|
|
|
|
closeCallable(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return storedEnum; |
|
|
|
return storedEnum; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public ConcurrentHashMap<Integer, Integer> GET_FRIENDS(final long buildingID) { |
|
|
|
public boolean updateBuildingRank(final Building b, int Rank) { |
|
|
|
ConcurrentHashMap<Integer, Integer> friendsList = new ConcurrentHashMap<>(); |
|
|
|
|
|
|
|
prepareCallable("SELECT * FROM `dyn_building_friends` WHERE `buildingUID`=?"); |
|
|
|
try (Connection connection = DbManager.getConnection(); |
|
|
|
setLong(1, buildingID); |
|
|
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_building` SET `rank`=?," |
|
|
|
try { |
|
|
|
+ "`upgradeDate`=?, `meshUUID`=?, `currentHP`=? " |
|
|
|
ResultSet rs = executeQuery(); |
|
|
|
+ "WHERE `UID` = ?")) { |
|
|
|
while (rs.next()) { |
|
|
|
|
|
|
|
int friendType = rs.getInt("friendType"); |
|
|
|
preparedStatement.setInt(1, Rank); |
|
|
|
switch (friendType) { |
|
|
|
preparedStatement.setNull(2, java.sql.Types.DATE); |
|
|
|
case 7: |
|
|
|
preparedStatement.setInt(3, b.getBlueprint().getMeshForRank(Rank)); |
|
|
|
friendsList.put(rs.getInt("playerUID"), 7); |
|
|
|
preparedStatement.setInt(4, b.getBlueprint().getMaxHealth(Rank)); |
|
|
|
break; |
|
|
|
preparedStatement.setInt(5, b.getObjectUUID()); |
|
|
|
case 8: |
|
|
|
|
|
|
|
friendsList.put(rs.getInt("guildUID"), 8); |
|
|
|
return (preparedStatement.executeUpdate() > 0); |
|
|
|
break; |
|
|
|
|
|
|
|
case 9: |
|
|
|
|
|
|
|
friendsList.put(rs.getInt("guildUID"), 9); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rs.close(); |
|
|
|
|
|
|
|
} catch (SQLException e) { |
|
|
|
} catch (SQLException e) { |
|
|
|
Logger.error("dbBuildingHandler.GET_FRIENDS_GUILD_IC", e); |
|
|
|
Logger.error(e); |
|
|
|
} finally { |
|
|
|
return false; |
|
|
|
closeCallable(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return friendsList; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public boolean updateBuildingRank(final Building b, int Rank) { |
|
|
|
public boolean updateReverseKOS(final Building b, boolean reverse) { |
|
|
|
|
|
|
|
|
|
|
|
prepareCallable("UPDATE `obj_building` SET `rank`=?," |
|
|
|
try (Connection connection = DbManager.getConnection(); |
|
|
|
+ "`upgradeDate`=?, `meshUUID`=?, `currentHP`=? " |
|
|
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_building` SET `reverseKOS`=? WHERE `UID` = ?")) { |
|
|
|
+ "WHERE `UID` = ?"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setInt(1, Rank); |
|
|
|
preparedStatement.setBoolean(1, reverse); |
|
|
|
setNULL(2, java.sql.Types.DATE); |
|
|
|
preparedStatement.setInt(2, b.getObjectUUID()); |
|
|
|
setInt(3, b.getBlueprint().getMeshForRank(Rank)); |
|
|
|
|
|
|
|
setInt(4, b.getBlueprint().getMaxHealth(Rank)); |
|
|
|
|
|
|
|
setInt(5, b.getObjectUUID()); |
|
|
|
|
|
|
|
return (executeUpdate() > 0); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public boolean updateReverseKOS(final Building b, boolean reverse) { |
|
|
|
return (preparedStatement.executeUpdate() > 0); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (SQLException e) { |
|
|
|
|
|
|
|
Logger.error(e); |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
prepareCallable("UPDATE `obj_building` SET `reverseKOS`=? " |
|
|
|
|
|
|
|
+ "WHERE `UID` = ?"); |
|
|
|
|
|
|
|
setBoolean(1, reverse); |
|
|
|
|
|
|
|
setInt(2, b.getObjectUUID()); |
|
|
|
|
|
|
|
return (executeUpdate() > 0); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public boolean updateActiveCondemn(final Condemned condemn, boolean active) { |
|
|
|
public boolean updateActiveCondemn(final Condemned condemn, boolean active) { |
|
|
|
|
|
|
|
|
|
|
|
prepareCallable("UPDATE `dyn_building_condemned` SET `active`=? " |
|
|
|
try (Connection connection = DbManager.getConnection(); |
|
|
|
+ "WHERE`buildingUID` = ? AND `playerUID` = ? AND `guildUID` = ? AND `friendType` = ?"); |
|
|
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `dyn_building_condemned` SET `active`=? " |
|
|
|
setBoolean(1, active); |
|
|
|
+ "WHERE`buildingUID` = ? AND `playerUID` = ? AND `guildUID` = ? AND `friendType` = ?")) { |
|
|
|
setInt(2, condemn.getParent()); |
|
|
|
|
|
|
|
setInt(3, condemn.getPlayerUID()); |
|
|
|
preparedStatement.setBoolean(1, active); |
|
|
|
setInt(4, condemn.getGuildUID()); |
|
|
|
preparedStatement.setInt(2, condemn.getParent()); |
|
|
|
setInt(5, condemn.getFriendType()); |
|
|
|
preparedStatement.setInt(3, condemn.getPlayerUID()); |
|
|
|
return (executeUpdate() > 0); |
|
|
|
preparedStatement.setInt(4, condemn.getGuildUID()); |
|
|
|
|
|
|
|
preparedStatement.setInt(5, condemn.getFriendType()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (preparedStatement.executeUpdate() > 0); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (SQLException e) { |
|
|
|
|
|
|
|
Logger.error(e); |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public boolean updateBuildingOwner(final Building building, int ownerUUID) { |
|
|
|
public boolean updateBuildingOwner(final Building building, int ownerUUID) { |
|
|
|
|
|
|
|
|
|
|
|
prepareCallable("UPDATE `obj_building` SET `ownerUUID`=? " |
|
|
|
try (Connection connection = DbManager.getConnection(); |
|
|
|
+ " WHERE `UID` = ?"); |
|
|
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_building` SET `ownerUUID`=? " |
|
|
|
|
|
|
|
+ " WHERE `UID` = ?")) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
preparedStatement.setInt(1, ownerUUID); |
|
|
|
|
|
|
|
preparedStatement.setInt(2, building.getObjectUUID()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (preparedStatement.executeUpdate() > 0); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (SQLException e) { |
|
|
|
|
|
|
|
Logger.error(e); |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
setInt(1, ownerUUID); |
|
|
|
|
|
|
|
setInt(2, building.getObjectUUID()); |
|
|
|
|
|
|
|
return (executeUpdate() > 0); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public boolean updateBuildingUpgradeTime(LocalDateTime upgradeDateTime, Building toUpgrade, int costToUpgrade) { |
|
|
|
public boolean updateBuildingUpgradeTime(LocalDateTime upgradeDateTime, Building toUpgrade, int costToUpgrade) { |
|
|
|
|
|
|
|
|
|
|
|
prepareCallable("UPDATE obj_building SET upgradeDate=?, currentGold=? " |
|
|
|
try (Connection connection = DbManager.getConnection(); |
|
|
|
+ "WHERE UID = ?"); |
|
|
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE obj_building SET upgradeDate=?, currentGold=? " |
|
|
|
|
|
|
|
+ "WHERE UID = ?")) { |
|
|
|
|
|
|
|
|
|
|
|
if (upgradeDateTime == null) |
|
|
|
if (upgradeDateTime == null) |
|
|
|
setNULL(1, java.sql.Types.DATE); |
|
|
|
preparedStatement.setNull(1, java.sql.Types.DATE); |
|
|
|
else |
|
|
|
else |
|
|
|
setTimeStamp(1, upgradeDateTime.atZone(ZoneId.systemDefault()) |
|
|
|
preparedStatement.setTimestamp(1, new java.sql.Timestamp(upgradeDateTime.atZone(ZoneId.systemDefault()) |
|
|
|
.toInstant().toEpochMilli()); |
|
|
|
.toInstant().toEpochMilli())); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
preparedStatement.setInt(2, toUpgrade.getStrongboxValue() - costToUpgrade); |
|
|
|
|
|
|
|
preparedStatement.setInt(3, toUpgrade.getObjectUUID()); |
|
|
|
|
|
|
|
|
|
|
|
setInt(2, toUpgrade.getStrongboxValue() - costToUpgrade); |
|
|
|
return (preparedStatement.executeUpdate() > 0); |
|
|
|
setInt(3, toUpgrade.getObjectUUID()); |
|
|
|
|
|
|
|
return (executeUpdate() > 0); |
|
|
|
} catch (SQLException e) { |
|
|
|
|
|
|
|
Logger.error(e); |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public boolean updateMaintDate(Building building) { |
|
|
|
public boolean updateMaintDate(Building building) { |
|
|
|
|
|
|
|
|
|
|
|
prepareCallable("UPDATE obj_building SET maintDate=? " |
|
|
|
try (Connection connection = DbManager.getConnection(); |
|
|
|
+ "WHERE UID = ?"); |
|
|
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE obj_building SET maintDate=? " |
|
|
|
|
|
|
|
+ "WHERE UID = ?")) { |
|
|
|
|
|
|
|
|
|
|
|
if (building.maintDateTime == null) |
|
|
|
if (building.maintDateTime == null) |
|
|
|
setNULL(1, java.sql.Types.DATE); |
|
|
|
preparedStatement.setNull(1, java.sql.Types.DATE); |
|
|
|
else |
|
|
|
else |
|
|
|
setLocalDateTime(1, building.maintDateTime); |
|
|
|
preparedStatement.setTimestamp(1, new java.sql.Timestamp(building.maintDateTime.atZone(ZoneId.systemDefault()) |
|
|
|
|
|
|
|
.toInstant().toEpochMilli())); |
|
|
|
|
|
|
|
preparedStatement.setInt(2, building.getObjectUUID()); |
|
|
|
|
|
|
|
|
|
|
|
setInt(2, building.getObjectUUID()); |
|
|
|
return (preparedStatement.executeUpdate() > 0); |
|
|
|
|
|
|
|
|
|
|
|
return (executeUpdate() > 0); |
|
|
|
} catch (SQLException e) { |
|
|
|
|
|
|
|
Logger.error(e); |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public boolean addTaxes(Building building, TaxType taxType, int amount, boolean enforceKOS){ |
|
|
|
public boolean addTaxes(Building building, TaxType taxType, int amount, boolean enforceKOS) { |
|
|
|
prepareCallable("UPDATE obj_building SET taxType=?, taxAmount = ?, enforceKOS = ? " |
|
|
|
|
|
|
|
+ "WHERE UID = ?"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setString(1, taxType.name()); |
|
|
|
try (Connection connection = DbManager.getConnection(); |
|
|
|
setInt(2, amount); |
|
|
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE obj_building SET taxType=?, taxAmount = ?, enforceKOS = ? " |
|
|
|
setBoolean(3, enforceKOS); |
|
|
|
+ "WHERE UID = ?")) { |
|
|
|
setInt(4, building.getObjectUUID()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (executeUpdate() > 0); |
|
|
|
preparedStatement.setString(1, taxType.name()); |
|
|
|
|
|
|
|
preparedStatement.setInt(2, amount); |
|
|
|
|
|
|
|
preparedStatement.setBoolean(3, enforceKOS); |
|
|
|
|
|
|
|
preparedStatement.setInt(4, building.getObjectUUID()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (preparedStatement.executeUpdate() > 0); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (SQLException e) { |
|
|
|
|
|
|
|
Logger.error(e); |
|
|
|
|
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public boolean removeTaxes(Building building){ |
|
|
|
} |
|
|
|
prepareCallable("UPDATE obj_building SET taxType=?, taxAmount = ?, enforceKOS = ?, taxDate = ? " |
|
|
|
|
|
|
|
+ "WHERE UID = ?"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setString(1, TaxType.NONE.name()); |
|
|
|
public boolean removeTaxes(Building building) { |
|
|
|
setInt(2, 0); |
|
|
|
|
|
|
|
setBoolean(3, false); |
|
|
|
|
|
|
|
setNULL(4, java.sql.Types.DATE); |
|
|
|
|
|
|
|
setInt(5, building.getObjectUUID()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try (Connection connection = DbManager.getConnection(); |
|
|
|
|
|
|
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE obj_building SET taxType=?, taxAmount = ?, enforceKOS = ?, taxDate = ? " |
|
|
|
|
|
|
|
+ "WHERE UID = ?")) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
preparedStatement.setString(1, TaxType.NONE.name()); |
|
|
|
|
|
|
|
preparedStatement.setInt(2, 0); |
|
|
|
|
|
|
|
preparedStatement.setBoolean(3, false); |
|
|
|
|
|
|
|
preparedStatement.setNull(4, java.sql.Types.DATE); |
|
|
|
|
|
|
|
preparedStatement.setInt(5, building.getObjectUUID()); |
|
|
|
|
|
|
|
|
|
|
|
return (executeUpdate() > 0); |
|
|
|
return (preparedStatement.executeUpdate() > 0); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (SQLException e) { |
|
|
|
|
|
|
|
Logger.error(e); |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public boolean acceptTaxes(Building building) { |
|
|
|
public boolean acceptTaxes(Building building) { |
|
|
|
|
|
|
|
|
|
|
|
prepareCallable("UPDATE obj_building SET taxDate=? " |
|
|
|
try (Connection connection = DbManager.getConnection(); |
|
|
|
+ "WHERE UID = ?"); |
|
|
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE obj_building SET taxDate=? " |
|
|
|
|
|
|
|
+ "WHERE UID = ?")) { |
|
|
|
setTimeStamp(1, DateTime.now().plusDays(7).getMillis()); |
|
|
|
|
|
|
|
setInt(2, building.getObjectUUID()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (executeUpdate() > 0); |
|
|
|
preparedStatement.setTimestamp(1, new java.sql.Timestamp(DateTime.now().plusDays(7).getMillis())); |
|
|
|
} |
|
|
|
preparedStatement.setInt(2, building.getObjectUUID()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (preparedStatement.executeUpdate() > 0); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (SQLException e) { |
|
|
|
|
|
|
|
Logger.error(e); |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|