From 457ed4f4e6cc256781239d25690f7aa55cf32acb Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 11 Feb 2024 23:41:24 -0600 Subject: [PATCH] mine show in system chat updated numbers --- src/engine/objects/Mine.java | 54 +++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 19 deletions(-) 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()); + } } } }