Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/main/java/pw/kaboom/extras/commands/CommandPrefix.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import javax.annotation.Nonnull;

public final class CommandPrefix implements CommandExecutor {

private static final int MAX_PREFIX_LENGTH = 1024;

public boolean onCommand(final @Nonnull CommandSender sender,
final @Nonnull Command cmd,
Expand All @@ -36,8 +36,12 @@ public boolean onCommand(final @Nonnull CommandSender sender,
player.sendMessage(Component
.text("You no longer have a tag"));
} else {
final Component prefix = PlayerPrefix.setPrefix(player, String.join(" ", args));
String legacyPrefix = String.join(" ", args);
if (legacyPrefix.length() > MAX_PREFIX_LENGTH) {
legacyPrefix = legacyPrefix.substring(0, MAX_PREFIX_LENGTH);
}

final Component prefix = PlayerPrefix.setPrefix(player, legacyPrefix);
player.sendMessage(Component.text("You now have the tag: ")
.append(prefix));
}
Expand Down