diff options
author | snowleo <schneeleo@gmail.com> | 2011-11-20 16:43:38 +0100 |
---|---|---|
committer | snowleo <schneeleo@gmail.com> | 2011-11-20 16:43:38 +0100 |
commit | 14cc49942102856cc076d654cc2a4ad4041b789d (patch) | |
tree | bdf7752e228d0e09c626f9a2478b63ca173ac741 | |
parent | 6633b3995421c6448c10742cf851aefe99ed1e1e (diff) | |
download | Essentials-14cc49942102856cc076d654cc2a4ad4041b789d.tar Essentials-14cc49942102856cc076d654cc2a4ad4041b789d.tar.gz Essentials-14cc49942102856cc076d654cc2a4ad4041b789d.tar.lz Essentials-14cc49942102856cc076d654cc2a4ad4041b789d.tar.xz Essentials-14cc49942102856cc076d654cc2a4ad4041b789d.zip |
Fix long prefix breaking setPlayerListName(), because they are too long.
If Essentials detects, that the player name would be too long with prefix and suffix to fit in the player list, it will only update the name without prefix and suffix but with nickname and opcolor.
4 files changed, 18 insertions, 13 deletions
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<User>, 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<User>, IReplyTo, IUser } } - if (ess.getSettings().addPrefixSuffix()) + if (addprefixsuffix && ess.getSettings().addPrefixSuffix()) { if (!ess.getSettings().disablePrefix()) { @@ -284,11 +284,16 @@ public class User extends UserData implements Comparable<User>, 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); } try @@ -306,7 +311,7 @@ public class User extends UserData implements Comparable<User>, 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; |