diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java index 2768b566e..e09eb9679 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java @@ -39,7 +39,7 @@ public class EssentialsPlayerListener extends PlayerListener updateCompass(user); if (ess.getSettings().changeDisplayName()) { - user.setDisplayNick(user.getNick()); + user.setDisplayNick(); } } @@ -65,7 +65,7 @@ public class EssentialsPlayerListener extends PlayerListener user.updateActivity(true); if (ess.getSettings().changeDisplayName()) { - user.setDisplayNick(user.getNick()); + user.setDisplayNick(); } } @@ -155,7 +155,7 @@ public class EssentialsPlayerListener extends PlayerListener if (ess.getSettings().changeDisplayName()) { - user.setDisplayNick(user.getNick()); + user.setDisplayNick(); } user.setLastLoginAddress(user.getAddress().getAddress().getHostAddress()); user.updateActivity(false); @@ -248,7 +248,7 @@ public class EssentialsPlayerListener extends PlayerListener final User user = ess.getUser(event.getPlayer()); if (ess.getSettings().changeDisplayName()) { - user.setDisplayNick(user.getNick()); + user.setDisplayNick(); } updateCompass(user); } diff --git a/Essentials/src/com/earth2me/essentials/User.java b/Essentials/src/com/earth2me/essentials/User.java index f4ded533c..8a5dd3138 100644 --- a/Essentials/src/com/earth2me/essentials/User.java +++ b/Essentials/src/com/earth2me/essentials/User.java @@ -235,7 +235,7 @@ public class User extends UserData implements Comparable, IReplyTo, IUser return teleportRequestHere; } - public String getNick() + public String getNick(boolean addprefixsuffix) { final StringBuilder nickname = new StringBuilder(); final String nick = getNickname(); @@ -259,7 +259,7 @@ public class User extends UserData implements Comparable, IReplyTo, IUser } } - if (ess.getSettings().addPrefixSuffix()) + if (addprefixsuffix && ess.getSettings().addPrefixSuffix()) { if (!ess.getSettings().disablePrefix()) { @@ -284,10 +284,15 @@ public class User extends UserData implements Comparable, IReplyTo, IUser return nickname.toString(); } - public void setDisplayNick(String name) + public void setDisplayNick() { + String name = getNick(true); setDisplayName(name); if (name.length() > 16) + { + name = getNick(false); + } + if (name.length() > 16) { name = name.substring(0, name.charAt(15) == '§' ? 15 : 16); } @@ -306,7 +311,7 @@ public class User extends UserData implements Comparable, IReplyTo, IUser { if (!(base instanceof OfflinePlayer) && ess.getSettings().changeDisplayName()) { - setDisplayNick(getNick()); + setDisplayNick(); } return super.getDisplayName() == null ? super.getName() : super.getDisplayName(); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandnick.java b/Essentials/src/com/earth2me/essentials/commands/Commandnick.java index e3e9d0b67..fa46cf3d4 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandnick.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandnick.java @@ -61,8 +61,8 @@ public class Commandnick extends EssentialsCommand } else if ("off".equalsIgnoreCase(nick) || target.getName().equalsIgnoreCase(nick)) { - target.setDisplayNick(target.getName()); target.setNickname(null); + target.setDisplayNick(); target.sendMessage(Util.i18n("nickNoMore")); } else @@ -83,8 +83,8 @@ public class Commandnick extends EssentialsCommand } } - target.setDisplayNick(ess.getSettings().getNicknamePrefix() + formattedNick); target.setNickname(formattedNick); + target.setDisplayNick(); target.sendMessage(Util.format("nickSet", target.getDisplayName() + "§7.")); } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java b/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java index b8081d04e..c99503eef 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java @@ -43,9 +43,9 @@ public class Commandwhois extends EssentialsCommand { continue; } - final String displayName = ChatColor.stripColor(user.getNick()); - if (!whois.equalsIgnoreCase(displayName) - && !whois.equalsIgnoreCase(displayName.substring(prefixLength)) + final String nickName = ChatColor.stripColor(user.getNickname()); + if (!whois.equalsIgnoreCase(nickName) + && !whois.substring(prefixLength).equalsIgnoreCase(nickName) && !whois.equalsIgnoreCase(user.getName())) { continue;