From 437d3916c9d70534aa84a2f30019d96845b240ad Mon Sep 17 00:00:00 2001 From: sweetfox86 <148832806+sweetfox86@users.noreply.github.com> Date: Sat, 28 Oct 2023 22:30:01 +0000 Subject: [PATCH] Fix online counter --- .../networking/http/api/custom/ListPlayersHandler.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/asf/centuria/networking/http/api/custom/ListPlayersHandler.java b/src/main/java/org/asf/centuria/networking/http/api/custom/ListPlayersHandler.java index d10fab87..6bd0bf42 100644 --- a/src/main/java/org/asf/centuria/networking/http/api/custom/ListPlayersHandler.java +++ b/src/main/java/org/asf/centuria/networking/http/api/custom/ListPlayersHandler.java @@ -28,13 +28,15 @@ 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 maps = new HashMap(); for (Player plr : Centuria.gameServer.getPlayers()) { if (!plr.roomReady) continue; + counter++; String map = Integer.toString(plr.levelID); if (plr.levelID == 25280) map = "Tutorial"; @@ -42,7 +44,8 @@ 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);