Browse Source

mine show in system chat updated numbers

lakebane-master
FatBoy-DOTC 9 months ago
parent
commit
457ed4f4e6
  1. 40
      src/engine/objects/Mine.java

40
src/engine/objects/Mine.java

@ -600,6 +600,7 @@ public class Mine extends AbstractGameObject { @@ -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,48 +608,63 @@ public class Mine extends AbstractGameObject { @@ -607,48 +608,63 @@ 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<PlayerCharacter> present = new ArrayList<>();
present.add(player);
this.presentPlayers.put(nation, present);
added = true;
}
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<Guild,ArrayList<PlayerCharacter>> checkList) {
ArrayList<PlayerCharacter> allPlayers = new ArrayList<>();
for(ArrayList<PlayerCharacter> players: presentPlayers.values()){
allPlayers.addAll(players);
}
boolean updated = false;
HashSet<AbstractWorldObject> 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) {
for (PlayerCharacter playerObject : allPlayers) {
if (playerObject == null)
continue;
player = (PlayerCharacter) playerObject;
Guild nation = player.getGuild().getNation();
if (currentPlayers.contains(playerObject) == false) {
Guild nation = playerObject.getGuild().getNation();
if (this.presentPlayers.containsKey(nation)) {
if (this.presentPlayers.get(nation).contains(player) == false)
{
this.presentPlayers.get(nation).remove(player);
if (this.presentPlayers.get(nation).contains(playerObject) == true) {
this.presentPlayers.get(nation).remove(playerObject);
updated = true;
ChatManager.chatSystemInfo(playerObject,"Leaving Mine Vicinity");
}
}
}
if(updated)
for (Guild guild : this.presentPlayers.keySet()) {
ChatManager.chatSystemInfo(player, "Guild: " + guild.getName() + " COUNT: " + presentPlayers.get(guild).size());
ChatManager.chatSystemInfo(playerObject, "Guild: " + guild.getName() + " COUNT: " + presentPlayers.get(guild).size());
}
}
}

Loading…
Cancel
Save