Skip to content
This repository has been archived by the owner on Apr 6, 2024. It is now read-only.

Commit

Permalink
feat: Don't count color codes for length limit
Browse files Browse the repository at this point in the history
  • Loading branch information
kiriDevs committed May 8, 2021
1 parent c1e72e0 commit 3b40052
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main/java/de/kiridevs/kiricore/commands/CMDrename.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,13 @@ public boolean onCommand(
// Allowing for colors by interpreting &colorCodes
newName = ChatColor.translateAlternateColorCodes('&', newName);

// Disregarding color codes for length limitation
String newNameNoColor = newName.replace("§", "");
int numberOfColorCodes = newName.length() - newNameNoColor.length();
int nameLength = newName.length() - numberOfColorCodes*2;

// Enforce 35 character length limit
if (newName.length() >= 35) {
if (nameLength >= 35) {
messageService.sendErrorMessage(cmdSender,
"This name is too long! " +
"The maximum is 35 characters, " +
Expand Down

0 comments on commit 3b40052

Please sign in to comment.