Garbage cleanup in SetZone().

Package reformat.
This commit is contained in:
2023-05-23 10:27:03 -04:00
parent a2d62ec221
commit 6dd7315786
29 changed files with 2901 additions and 2937 deletions
+75 -75
View File
@@ -23,113 +23,113 @@ import java.util.ArrayList;
public class dbMineHandler extends dbHandlerBase {
public dbMineHandler() {
this.localClass = Mine.class;
this.localObjectType = Enum.GameObjectType.valueOf(this.localClass.getSimpleName());
}
public dbMineHandler() {
this.localClass = Mine.class;
this.localObjectType = Enum.GameObjectType.valueOf(this.localClass.getSimpleName());
}
public Mine GET_MINE(int id) {
public Mine GET_MINE(int id) {
if (id == 0)
return null;
if (id == 0)
return null;
Mine mine = (Mine) DbManager.getFromCache(Enum.GameObjectType.Mine, id);
Mine mine = (Mine) DbManager.getFromCache(Enum.GameObjectType.Mine, id);
if (mine != null)
return mine;
if (mine != null)
return mine;
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` = ?;")) {
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.setLong(1, id);
preparedStatement.setLong(1, id);
ResultSet rs = preparedStatement.executeQuery();
mine = (Mine) getObjectFromRs(rs);
ResultSet rs = preparedStatement.executeQuery();
mine = (Mine) getObjectFromRs(rs);
} catch (SQLException e) {
Logger.error(e);
}
return mine;
}
} catch (SQLException e) {
Logger.error(e);
}
return mine;
}
public ArrayList<Mine> GET_ALL_MINES_FOR_SERVER() {
public ArrayList<Mine> GET_ALL_MINES_FOR_SERVER() {
ArrayList<Mine> mines = new ArrayList<>();
ArrayList<Mine> mines = new ArrayList<>();
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_mine`.*, `object`.`parent` FROM `object` INNER JOIN `obj_mine` ON `obj_mine`.`UID` = `object`.`UID`")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_mine`.*, `object`.`parent` FROM `object` INNER JOIN `obj_mine` ON `obj_mine`.`UID` = `object`.`UID`")) {
ResultSet rs = preparedStatement.executeQuery();
mines = getObjectsFromRs(rs, 1000);
ResultSet rs = preparedStatement.executeQuery();
mines = getObjectsFromRs(rs, 1000);
} catch (SQLException e) {
Logger.error(e);
}
return mines;
}
} catch (SQLException e) {
Logger.error(e);
}
return mines;
}
public boolean CHANGE_OWNER(Mine mine, int playerUID) {
public boolean CHANGE_OWNER(Mine mine, int playerUID) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_mine` SET `mine_ownerUID`=? WHERE `UID`=?")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_mine` SET `mine_ownerUID`=? WHERE `UID`=?")) {
preparedStatement.setInt(1, playerUID);
preparedStatement.setLong(2, mine.getObjectUUID());
preparedStatement.setInt(1, playerUID);
preparedStatement.setLong(2, mine.getObjectUUID());
return (preparedStatement.executeUpdate() > 0);
return (preparedStatement.executeUpdate() > 0);
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
public boolean CHANGE_RESOURCE(Mine mine, Resource resource) {
public boolean CHANGE_RESOURCE(Mine mine, Resource resource) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_mine` SET `mine_resource`=? WHERE `UID`=?")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_mine` SET `mine_resource`=? WHERE `UID`=?")) {
preparedStatement.setString(1, resource.name());
preparedStatement.setLong(2, mine.getObjectUUID());
preparedStatement.setString(1, resource.name());
preparedStatement.setLong(2, mine.getObjectUUID());
return (preparedStatement.executeUpdate() > 0);
return (preparedStatement.executeUpdate() > 0);
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
public boolean CHANGE_TYPE(Mine mine, MineProduction productionType) {
public boolean CHANGE_TYPE(Mine mine, MineProduction productionType) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_mine` SET `mine_type`=? WHERE `UID`=?")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_mine` SET `mine_type`=? WHERE `UID`=?")) {
preparedStatement.setString(1, productionType.name());
preparedStatement.setLong(2, mine.getObjectUUID());
preparedStatement.setString(1, productionType.name());
preparedStatement.setLong(2, mine.getObjectUUID());
return (preparedStatement.executeUpdate() > 0);
return (preparedStatement.executeUpdate() > 0);
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
public boolean SET_FLAGS(Mine mine, int newFlags) {
public boolean SET_FLAGS(Mine mine, int newFlags) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_mine` SET `flags`=? WHERE `UID`=?")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_mine` SET `flags`=? WHERE `UID`=?")) {
preparedStatement.setInt(1, newFlags);
preparedStatement.setLong(2, mine.getObjectUUID());
preparedStatement.setInt(1, newFlags);
preparedStatement.setLong(2, mine.getObjectUUID());
return (preparedStatement.executeUpdate() > 0);
return (preparedStatement.executeUpdate() > 0);
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
}