From e2d0d6832381903af5c0ce13068078178c0b94ab Mon Sep 17 00:00:00 2001 From: JRoy <10731363+JRoy@users.noreply.github.com> Date: Fri, 27 Jun 2025 23:32:39 -0700 Subject: [PATCH] Fix max nick length with hex color codes 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. --- .../java/com/earth2me/essentials/commands/Commandnick.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandnick.java b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandnick.java index 7648cbc74f5..9716816e126 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandnick.java +++ b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandnick.java @@ -5,7 +5,6 @@ import com.earth2me.essentials.utils.FormatUtil; import net.ess3.api.TranslatableException; import net.ess3.api.events.NickChangeEvent; -import org.bukkit.ChatColor; import org.bukkit.Server; import java.util.Collections; @@ -87,7 +86,10 @@ private boolean isNickBanned(final String newNick) { } private int getNickLength(final String nick) { - return ess.getSettings().ignoreColorsInMaxLength() ? ChatColor.stripColor(nick).length() : nick.length(); + if (ess.getSettings().ignoreColorsInMaxLength()) { + return FormatUtil.stripFormat(nick).length(); + } + return FormatUtil.unformatString(nick).length(); } private boolean nickInUse(final User target, final String nick) {