Add 'includehiddenplayers' for client component (shows online status only)

This commit is contained in:
Mike Primm 2011-10-01 17:38:31 -05:00
parent 0cb9a2c2fe
commit 150f3ae6f4
3 changed files with 34 additions and 0 deletions

View File

@ -3,6 +3,8 @@ package org.dynmap;
import static org.dynmap.JSONUtils.a;
import static org.dynmap.JSONUtils.s;
import java.util.Set;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
@ -67,6 +69,22 @@ public class ClientUpdateComponent extends Component {
}
a(u, "players", jp);
}
if(configuration.getBoolean("includehiddenplayers", false)) {
Set<Player> hidden = plugin.playerList.getHiddenPlayers();
for(Player p : hidden) {
JSONObject jp = new JSONObject();
s(jp, "type", "player");
s(jp, "name", ChatColor.stripColor(p.getDisplayName()));
s(jp, "account", p.getName());
s(jp, "world", "-hidden-player-");
s(jp, "x", 0.0);
s(jp, "y", 64.0);
s(jp, "z", 0.0);
s(jp, "health", 0);
s(jp, "armor", 0);
a(u, "players", jp);
}
}
s(u, "updates", new JSONArray());
for(Object update : plugin.mapManager.getWorldUpdates(worldName, since)) {

View File

@ -9,6 +9,7 @@ import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
import org.bukkit.Server;
import org.bukkit.entity.Player;
@ -101,4 +102,17 @@ public class PlayerList {
visiblePlayers.toArray(result);
return result;
}
public Set<Player> getHiddenPlayers() {
HashSet<Player> hidden = new HashSet<Player>();
Player[] onlinePlayers = server.getOnlinePlayers();
boolean useWhitelist = configuration.getBoolean("display-whitelist", false);
for (int i = 0; i < onlinePlayers.length; i++) {
Player p = onlinePlayers[i];
if (useWhitelist ^ hiddenPlayerNames.contains(p.getName().toLowerCase())) {
hidden.add(p);
}
}
return hidden;
}
}

View File

@ -21,6 +21,7 @@ components:
webchat-interval: 5
hidewebchatip: false
trustclientname: false
includehiddenplayers: false
#- class: org.dynmap.JsonFileClientUpdateComponent
# writeinterval: 1
# sendhealth: true
@ -28,6 +29,7 @@ components:
# allowwebchat: false
# webchat-interval: 5
# hidewebchatip: false
# includehiddenplayers: false
- class: org.dynmap.SimpleWebChatComponent
allowchat: true