Skip to content

Commit 6100ced

Browse files
authored
Fix max nick length with hex color codes (#6185)
Hex color codes convert to the obnoxious md5 format which massively inflates the character count than what the user entered. Unformat the nickname before getting the length to remain true to what the user entered as the command argument. Fixes #6174
1 parent e6b8493 commit 6100ced

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Essentials/src/main/java/com/earth2me/essentials/commands/Commandnick.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import com.earth2me.essentials.utils.FormatUtil;
66
import net.ess3.api.TranslatableException;
77
import net.ess3.api.events.NickChangeEvent;
8-
import org.bukkit.ChatColor;
98
import org.bukkit.Server;
109

1110
import java.util.Collections;
@@ -87,7 +86,10 @@ private boolean isNickBanned(final String newNick) {
8786
}
8887

8988
private int getNickLength(final String nick) {
90-
return ess.getSettings().ignoreColorsInMaxLength() ? ChatColor.stripColor(nick).length() : nick.length();
89+
if (ess.getSettings().ignoreColorsInMaxLength()) {
90+
return FormatUtil.stripFormat(nick).length();
91+
}
92+
return FormatUtil.unformatString(nick).length();
9193
}
9294

9395
private boolean nickInUse(final User target, final String nick) {

0 commit comments

Comments
 (0)