mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-11-13 05:54:40 +01:00
Handle Essentials-style nickname color coding (&0-&f) in player nicknames
This commit is contained in:
parent
eafbe62c46
commit
b872aa039e
@ -34,7 +34,7 @@ public class Client {
|
||||
public String channel;
|
||||
public ChatMessage(String source, String channel, String playerName, String message, String playeraccount) {
|
||||
this.source = source;
|
||||
this.playerName = ChatColor.stripColor(playerName);
|
||||
this.playerName = Client.stripColor(playerName);
|
||||
this.message = ChatColor.stripColor(message);
|
||||
this.account = playeraccount;
|
||||
this.channel = channel;
|
||||
@ -58,7 +58,7 @@ public class Client {
|
||||
public String playerName;
|
||||
public String account;
|
||||
public PlayerJoinMessage(String playerName, String playeraccount) {
|
||||
this.playerName = ChatColor.stripColor(playerName);
|
||||
this.playerName = Client.stripColor(playerName);
|
||||
this.account = playeraccount;
|
||||
}
|
||||
@Override
|
||||
@ -80,7 +80,7 @@ public class Client {
|
||||
public String playerName;
|
||||
public String account;
|
||||
public PlayerQuitMessage(String playerName, String playeraccount) {
|
||||
this.playerName = ChatColor.stripColor(playerName);
|
||||
this.playerName = Client.stripColor(playerName);
|
||||
this.account = playeraccount;
|
||||
}
|
||||
@Override
|
||||
@ -142,4 +142,21 @@ public class Client {
|
||||
public String type = "component";
|
||||
/* Each subclass must provide 'ctype' string for component 'type' */
|
||||
}
|
||||
|
||||
public static String stripColor(String s) {
|
||||
s = ChatColor.stripColor(s); /* Strip standard color encoding */
|
||||
/* Handle Essentials nickname encoding too */
|
||||
int idx = 0;
|
||||
while((idx = s.indexOf('&', idx)) >= 0) {
|
||||
char c = s.charAt(idx+1); /* Get next character */
|
||||
if(c == '&') { /* Another ampersand */
|
||||
s = s.substring(0, idx) + s.substring(idx+1);
|
||||
}
|
||||
else {
|
||||
s = s.substring(0, idx) + s.substring(idx+2);
|
||||
}
|
||||
idx++;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ public class ClientUpdateComponent extends Component {
|
||||
boolean hide = false;
|
||||
|
||||
s(jp, "type", "player");
|
||||
s(jp, "name", ChatColor.stripColor(p.getDisplayName()));
|
||||
s(jp, "name", Client.stripColor(p.getDisplayName()));
|
||||
s(jp, "account", p.getName());
|
||||
if(hideifshadow < 15) {
|
||||
if(pl.getBlock().getLightLevel() <= hideifshadow)
|
||||
@ -100,7 +100,7 @@ public class ClientUpdateComponent extends Component {
|
||||
for(Player p : hidden) {
|
||||
JSONObject jp = new JSONObject();
|
||||
s(jp, "type", "player");
|
||||
s(jp, "name", ChatColor.stripColor(p.getDisplayName()));
|
||||
s(jp, "name", Client.stripColor(p.getDisplayName()));
|
||||
s(jp, "account", p.getName());
|
||||
s(jp, "world", "-hidden-player-");
|
||||
s(jp, "x", 0.0);
|
||||
|
Loading…
Reference in New Issue
Block a user