mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
Calculate the player count without offline players (FS-247) (#68)
Co-authored-by: Ryan <Wild1145@users.noreply.github.com>
This commit is contained in:
parent
9ff5da8d8f
commit
d047cfc8ff
@ -101,8 +101,7 @@ public class Command_list extends FreedomCommand
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int count = server.getOnlinePlayers().size() - AdminList.vanished.size();
|
onlineStats.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(FUtil.getFakePlayerCount())
|
||||||
onlineStats.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(count < 0 ? 0 : count)
|
|
||||||
.append(ChatColor.BLUE)
|
.append(ChatColor.BLUE)
|
||||||
.append(" out of a maximum ")
|
.append(" out of a maximum ")
|
||||||
.append(ChatColor.RED)
|
.append(ChatColor.RED)
|
||||||
|
@ -88,8 +88,6 @@ 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
|
// 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("owners", owners);
|
||||||
responseObject.put("executives", executives);
|
responseObject.put("executives", executives);
|
||||||
@ -99,7 +97,7 @@ public class Module_list extends HTTPDModule
|
|||||||
responseObject.put("master_builders", masterbuilders);
|
responseObject.put("master_builders", masterbuilders);
|
||||||
responseObject.put("operators", operators);
|
responseObject.put("operators", operators);
|
||||||
responseObject.put("imposters", imposters);
|
responseObject.put("imposters", imposters);
|
||||||
responseObject.put("online", count < 0 ? 0 : count);
|
responseObject.put("online", FUtil.getFakePlayerCount());
|
||||||
responseObject.put("max", server.getMaxPlayers());
|
responseObject.put("max", server.getMaxPlayers());
|
||||||
|
|
||||||
final NanoHTTPD.Response response = new NanoHTTPD.Response(NanoHTTPD.Response.Status.OK, NanoHTTPD.MIME_JSON, responseObject.toString());
|
final NanoHTTPD.Response response = new NanoHTTPD.Response(NanoHTTPD.Response.Status.OK, NanoHTTPD.MIME_JSON, responseObject.toString());
|
||||||
|
@ -838,6 +838,19 @@ public class FUtil
|
|||||||
}.runTaskLater(TotalFreedomMod.getPlugin(), delay);
|
}.runTaskLater(TotalFreedomMod.getPlugin(), delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int getFakePlayerCount()
|
||||||
|
{
|
||||||
|
int i = TotalFreedomMod.getPlugin().al.vanished.size();
|
||||||
|
for (String name : TotalFreedomMod.getPlugin().al.vanished)
|
||||||
|
{
|
||||||
|
if (Bukkit.getPlayer(name) == null)
|
||||||
|
{
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return getServer().getOnlinePlayers().size() - i;
|
||||||
|
}
|
||||||
|
|
||||||
public static class PaginationList<T> extends ArrayList<T>
|
public static class PaginationList<T> extends ArrayList<T>
|
||||||
{
|
{
|
||||||
private final int epp;
|
private final int epp;
|
||||||
|
Loading…
Reference in New Issue
Block a user