Browse Source

Collection used and old handler removed.

magicbox-1.5.2
MagicBot 1 year ago
parent
commit
5ac62d60be
  1. 30
      src/engine/db/handlers/dbBuildingHandler.java
  2. 5
      src/engine/objects/Building.java

30
src/engine/db/handlers/dbBuildingHandler.java

@ -458,36 +458,6 @@ public class dbBuildingHandler extends dbHandlerBase {
} }
public void LOAD_ALL_FRIENDS_FOR_BUILDING(Building building) {
if (building == null)
return;
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_building_friends` WHERE `buildingUID` = ?")) {
preparedStatement.setInt(1, building.getObjectUUID());
ResultSet rs = preparedStatement.executeQuery();
while (rs.next()) {
BuildingFriends friend = new BuildingFriends(rs);
switch (friend.friendType) {
case 7:
building.getFriends().put(friend.playerUID, friend);
break;
case 8:
case 9:
building.getFriends().put(friend.guildUID, friend);
break;
}
}
} catch (SQLException e) {
Logger.error(e);
}
}
public void LOAD_ALL_CONDEMNED_FOR_BUILDING(Building building) { public void LOAD_ALL_CONDEMNED_FOR_BUILDING(Building building) {
if (building == null) if (building == null)

5
src/engine/objects/Building.java

@ -94,7 +94,7 @@ public class Building extends AbstractWorldObject {
private boolean spireIsActive = false; private boolean spireIsActive = false;
private ConcurrentHashMap<String, JobContainer> timers = null; private ConcurrentHashMap<String, JobContainer> timers = null;
private ConcurrentHashMap<String, Long> timestamps = null; private ConcurrentHashMap<String, Long> timestamps = null;
private ConcurrentHashMap<Integer, BuildingFriends> friends = new ConcurrentHashMap<>(); private ConcurrentHashMap<Integer, BuildingFriends> friends;
private ConcurrentHashMap<Integer, Condemned> condemned = new ConcurrentHashMap<>(); private ConcurrentHashMap<Integer, Condemned> condemned = new ConcurrentHashMap<>();
public ProtectionState protectionState = ProtectionState.NONE; public ProtectionState protectionState = ProtectionState.NONE;
private ArrayList<Building> children = null; private ArrayList<Building> children = null;
@ -966,8 +966,9 @@ public class Building extends AbstractWorldObject {
Logger.error("Failed to find Object Type for owner " + this.ownerUUID + " Location " + this.getLoc().toString()); Logger.error("Failed to find Object Type for owner " + this.ownerUUID + " Location " + this.getLoc().toString());
} }
this.friends = BuildingManager._buildingFriends.get(this.getObjectUUID());
try { try {
DbManager.BuildingQueries.LOAD_ALL_FRIENDS_FOR_BUILDING(this);
DbManager.BuildingQueries.LOAD_ALL_CONDEMNED_FOR_BUILDING(this); DbManager.BuildingQueries.LOAD_ALL_CONDEMNED_FOR_BUILDING(this);
} catch (Exception e) { } catch (Exception e) {
Logger.error(this.getObjectUUID() + " failed to load friends/condemned." + e.getMessage()); Logger.error(this.getObjectUUID() + " failed to load friends/condemned." + e.getMessage());

Loading…
Cancel
Save