Skip to content

Commit

Permalink
Fix Online counter (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
sweetfox86 authored Oct 31, 2023
1 parent 0f30347 commit 0f9114c
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,24 @@ public void process(String path, String method, RemoteClient client, String cont
strm.close();
} catch (Exception e) {
}

// Send response
int counter = 0;
JsonObject response = new JsonObject();
HashMap<String, Integer> maps = new HashMap<String, Integer>();
for (Player plr : Centuria.gameServer.getPlayers()) {
if (!plr.roomReady)
continue;
counter++;
String map = Integer.toString(plr.levelID);
if (plr.levelID == 25280)
map = "Tutorial";
else if (helper.has(Integer.toString(plr.levelID)))
map = helper.get(Integer.toString(plr.levelID)).getAsString();
maps.put(map, maps.getOrDefault(map, 0) + 1);
}
response.addProperty("online", Centuria.gameServer.getPlayers().length);
response.addProperty("active", counter);
response.addProperty("connected", Centuria.gameServer.getPlayers().length);
JsonObject mapData = new JsonObject();
maps.forEach((k, v) -> mapData.addProperty(k, v));
response.add("maps", mapData);
Expand Down

0 comments on commit 0f9114c

Please sign in to comment.