mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-12-01 06:33:38 +01:00
Add 'includehiddenplayers' for client component (shows online status only)
This commit is contained in:
parent
0cb9a2c2fe
commit
150f3ae6f4
@ -3,6 +3,8 @@ package org.dynmap;
|
|||||||
import static org.dynmap.JSONUtils.a;
|
import static org.dynmap.JSONUtils.a;
|
||||||
import static org.dynmap.JSONUtils.s;
|
import static org.dynmap.JSONUtils.s;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -67,6 +69,22 @@ public class ClientUpdateComponent extends Component {
|
|||||||
}
|
}
|
||||||
a(u, "players", jp);
|
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());
|
s(u, "updates", new JSONArray());
|
||||||
for(Object update : plugin.mapManager.getWorldUpdates(worldName, since)) {
|
for(Object update : plugin.mapManager.getWorldUpdates(worldName, since)) {
|
||||||
|
@ -9,6 +9,7 @@ import java.io.OutputStreamWriter;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -101,4 +102,17 @@ public class PlayerList {
|
|||||||
visiblePlayers.toArray(result);
|
visiblePlayers.toArray(result);
|
||||||
return 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ components:
|
|||||||
webchat-interval: 5
|
webchat-interval: 5
|
||||||
hidewebchatip: false
|
hidewebchatip: false
|
||||||
trustclientname: false
|
trustclientname: false
|
||||||
|
includehiddenplayers: false
|
||||||
#- class: org.dynmap.JsonFileClientUpdateComponent
|
#- class: org.dynmap.JsonFileClientUpdateComponent
|
||||||
# writeinterval: 1
|
# writeinterval: 1
|
||||||
# sendhealth: true
|
# sendhealth: true
|
||||||
@ -28,6 +29,7 @@ components:
|
|||||||
# allowwebchat: false
|
# allowwebchat: false
|
||||||
# webchat-interval: 5
|
# webchat-interval: 5
|
||||||
# hidewebchatip: false
|
# hidewebchatip: false
|
||||||
|
# includehiddenplayers: false
|
||||||
|
|
||||||
- class: org.dynmap.SimpleWebChatComponent
|
- class: org.dynmap.SimpleWebChatComponent
|
||||||
allowchat: true
|
allowchat: true
|
||||||
|
Loading…
Reference in New Issue
Block a user