Cleanup of friend and condemned initialization.

This commit is contained in:
2023-10-19 07:59:44 -04:00
parent 5e629e7890
commit 4274e6a148
2 changed files with 29 additions and 25 deletions
+15 -4
View File
@@ -95,7 +95,7 @@ public class Building extends AbstractWorldObject {
private ConcurrentHashMap<String, JobContainer> timers = null;
private ConcurrentHashMap<String, Long> timestamps = null;
private ConcurrentHashMap<Integer, BuildingFriends> friends;
private ConcurrentHashMap<Integer, Condemned> condemned = new ConcurrentHashMap<>();
private ConcurrentHashMap<Integer, Condemned> condemned;
public ProtectionState protectionState = ProtectionState.NONE;
private ArrayList<Building> children = null;
@@ -969,17 +969,28 @@ public class Building extends AbstractWorldObject {
// Reference friend and condemn lists from BuildingManager
this.friends = BuildingManager._buildingFriends.get(this.getObjectUUID());
if (this.friends == null) {
this.friends = new ConcurrentHashMap<>();
BuildingManager._buildingFriends.put(this.getObjectUUID(), this.friends);
}
this.condemned = BuildingManager._buildingCondemned.get(this.getObjectUUID());
if (this.condemned == null) {
this.condemned = new ConcurrentHashMap<>();
BuildingManager._buildingCondemned.put(this.getObjectUUID(), this.condemned);
}
//LOad Owners in Cache so we do not have to continuely look in the db for owner.
if (this.ownerIsNPC) {
if (NPC.getNPC(this.ownerUUID) == null)
Logger.info("Building UID " + this.getObjectUUID() + " Failed to Load NPC Owner with ID " + this.ownerUUID + " Location " + this.getLoc().toString());
} else if (this.ownerUUID != 0) {
if (PlayerCharacter.getPlayerCharacter(this.ownerUUID) == null) {
Logger.info("Building UID " + this.getObjectUUID() + " Failed to Load Player Owner with ID " + this.ownerUUID + " Location " + this.getLoc().toString());
} else if (this.ownerUUID != 0) {
if (PlayerCharacter.getPlayerCharacter(this.ownerUUID) == null) {
Logger.info("Building UID " + this.getObjectUUID() + " Failed to Load Player Owner with ID " + this.ownerUUID + " Location " + this.getLoc().toString());
}
}