diff --git a/src/engine/objects/Mine.java b/src/engine/objects/Mine.java index a4c4a1eb..04d1596f 100644 --- a/src/engine/objects/Mine.java +++ b/src/engine/objects/Mine.java @@ -600,6 +600,7 @@ public class Mine extends AbstractGameObject { Building building = BuildingManager.getBuilding(this.buildingID); currentPlayers = WorldGrid.getObjectsInRangePartial(building.loc, Enum.CityBoundsType.ZONE.extents, MBServerStatics.MASK_PLAYER); this.totalPLayers = currentPlayers.size(); + boolean added = false; for (AbstractWorldObject playerObject : currentPlayers) { if (playerObject == null) @@ -607,49 +608,64 @@ public class Mine extends AbstractGameObject { player = (PlayerCharacter) playerObject; Guild nation = player.getGuild().getNation(); + + if(nation == null) + return; + if(this.presentPlayers.containsKey(nation)) { if (this.presentPlayers.get(nation).contains(player) == false) { this.presentPlayers.get(nation).add(player); + added = true; } } else { ArrayList present = new ArrayList<>(); present.add(player); this.presentPlayers.put(nation, present); + added = true; } - for(Guild guild : this.presentPlayers.keySet()) { - ChatManager.chatSystemInfo(player, "Guild: " + guild.getName() + " COUNT: " + presentPlayers.get(guild).size()); - } + if(added) + for(Guild guild : this.presentPlayers.keySet()) { + ChatManager.chatSystemInfo(player, "Guild: " + guild.getName() + " COUNT: " + presentPlayers.get(guild).size()); + } } try { - onExit(); + onExit(this.presentPlayers); } catch (Exception e) { Logger.error(e.getMessage()); } } - private void onExit() { + private void onExit(HashMap> checkList) { + ArrayList allPlayers = new ArrayList<>(); + for(ArrayList players: presentPlayers.values()){ + allPlayers.addAll(players); + } + + boolean updated = false; + HashSet currentPlayers; PlayerCharacter player; Building building = BuildingManager.getBuilding(this.buildingID); currentPlayers = WorldGrid.getObjectsInRangePartial(building.loc, Enum.CityBoundsType.ZONE.extents, MBServerStatics.MASK_PLAYER); this.totalPLayers = currentPlayers.size(); - for (AbstractWorldObject playerObject : currentPlayers) { - - if (playerObject == null) - continue; - - player = (PlayerCharacter) playerObject; - Guild nation = player.getGuild().getNation(); - if(this.presentPlayers.containsKey(nation)) { - if (this.presentPlayers.get(nation).contains(player) == false) - { - this.presentPlayers.get(nation).remove(player); + for (PlayerCharacter playerObject : allPlayers) { + + if (currentPlayers.contains(playerObject) == false) { + Guild nation = playerObject.getGuild().getNation(); + if (this.presentPlayers.containsKey(nation)) { + if (this.presentPlayers.get(nation).contains(playerObject) == true) { + this.presentPlayers.get(nation).remove(playerObject); + updated = true; + ChatManager.chatSystemInfo(playerObject,"Leaving Mine Vicinity"); + } } + } - for(Guild guild : this.presentPlayers.keySet()) { - ChatManager.chatSystemInfo(player, "Guild: " + guild.getName() + " COUNT: " + presentPlayers.get(guild).size()); - } + if(updated) + for (Guild guild : this.presentPlayers.keySet()) { + ChatManager.chatSystemInfo(playerObject, "Guild: " + guild.getName() + " COUNT: " + presentPlayers.get(guild).size()); + } } } }