From 6073712fdf7e8e0a3ff223d256bdc69bef81da44 Mon Sep 17 00:00:00 2001 From: Ryan Date: Mon, 26 Apr 2021 20:46:11 +0100 Subject: [PATCH 1/4] Bump Version Bump Version to 2021.04-RC01 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 99eb47d3..1ceea4b9 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ me.totalfreedom TotalFreedomMod - 2021.02-Patch.01-RC01 + 2021.04-RC01 jar From f240a15af3f6fdf675965ee0f46c4dd4e1d68d6d Mon Sep 17 00:00:00 2001 From: Nathan Curran <30569566+Focusvity@users.noreply.github.com> Date: Sat, 1 May 2021 23:58:03 +1000 Subject: [PATCH 2/4] Force the count to be zero if the value is negative (FS-216) (#56) --- .../totalfreedom/totalfreedommod/command/Command_list.java | 3 ++- .../totalfreedommod/httpd/module/Module_list.java | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_list.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_list.java index 402be4ab..f3a0ad94 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_list.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_list.java @@ -101,7 +101,8 @@ public class Command_list extends FreedomCommand } else { - onlineStats.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(server.getOnlinePlayers().size() - AdminList.vanished.size()) + int count = server.getOnlinePlayers().size() - AdminList.vanished.size(); + onlineStats.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(count < 0 ? 0 : count) .append(ChatColor.BLUE) .append(" out of a maximum ") .append(ChatColor.RED) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_list.java b/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_list.java index 81333e4b..ef40114c 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_list.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_list.java @@ -88,6 +88,8 @@ public class Module_list extends HTTPDModule } } + int count = server.getOnlinePlayers().size() - AdminList.vanished.size(); + // for future refernce - any multi-worded ranks are to be delimited by underscores in the json; eg. senior_admins responseObject.put("owners", owners); responseObject.put("executives", executives); @@ -97,7 +99,7 @@ public class Module_list extends HTTPDModule responseObject.put("master_builders", masterbuilders); responseObject.put("operators", operators); responseObject.put("imposters", imposters); - responseObject.put("online", server.getOnlinePlayers().size() - AdminList.vanished.size()); + responseObject.put("online", count < 0 ? 0 : count); responseObject.put("max", server.getMaxPlayers()); final NanoHTTPD.Response response = new NanoHTTPD.Response(NanoHTTPD.Response.Status.OK, NanoHTTPD.MIME_JSON, responseObject.toString()); @@ -110,7 +112,8 @@ public class Module_list extends HTTPDModule final Collection onlinePlayers = Bukkit.getOnlinePlayers(); - body.append("

There are ").append(onlinePlayers.size() - AdminList.vanished.size()).append("/") + int count = onlinePlayers.size() - AdminList.vanished.size(); + body.append("

There are ").append(count < 0 ? 0 : count).append("/") .append(Bukkit.getMaxPlayers()).append(" players online:

\r\n"); body.append("