Skip to content

Commit ed7b983

Browse files
committed
ensure descriptions don't exceed column max length
1 parent c143f16 commit ed7b983

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

src/main/java/pro/cloudnode/smp/bankaccounts/commands/BankCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ public static boolean transfer(final @NotNull CommandSender sender, final @NotNu
501501

502502
@Nullable String description = args.length > 3 ? String
503503
.join(" ", Arrays.copyOfRange(argsCopy, 3, argsCopy.length)).trim() : null;
504-
if (description != null && description.length() > 64) description = description.substring(0, 64);
504+
if (description != null && description.length() > 64) description = description.substring(0, 63) + "…";
505505

506506
final @NotNull Set<@NotNull String> disallowedChars = getDisallowedCharacters(description);
507507
if (!disallowedChars.isEmpty())

src/main/java/pro/cloudnode/smp/bankaccounts/commands/InvoiceCommand.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,9 @@ public static boolean create(final @NotNull CommandSender sender, @NotNull Strin
177177
if (account.get().frozen)
178178
return sendMessage(sender, BankAccounts.getInstance().config().messagesErrorsFrozen(account.get()));
179179

180-
final @Nullable String description = argsCopy.length < 3 ? null : String.join(" ", Arrays.copyOfRange(argsCopy, 2, argsCopy.length));
180+
@Nullable String description = argsCopy.length < 3 ? null : String.join(" ", Arrays.copyOfRange(argsCopy, 2, argsCopy.length));
181+
if (description != null && description.length() > 64) description = description.substring(0, 63) + "…";
182+
181183
final @NotNull Set<@NotNull String> disallowedChars = getDisallowedCharacters(description);
182184
if (!disallowedChars.isEmpty())
183185
return sendMessage(sender, BankAccounts.getInstance().config().messagesErrorsDisallowedCharacters(disallowedChars));

src/main/java/pro/cloudnode/smp/bankaccounts/commands/POSCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public boolean execute(final @NotNull CommandSender sender, final @NotNull Strin
7777
if (POS.get(chest).isPresent()) return sendMessage(sender, BankAccounts.getInstance().config().messagesErrorsPosAlreadyExists());
7878

7979
@Nullable String description = args.length > 2 ? String.join(" ", Arrays.copyOfRange(args, 2, args.length)) : null;
80-
if (description != null && description.length() > 64) description = description.substring(0, 64);
80+
if (description != null && description.length() > 64) description = description.substring(0, 63) + "…";
8181

8282
final @NotNull Set<@NotNull String> disallowedChars = getDisallowedCharacters(description);
8383
if (!disallowedChars.isEmpty())

0 commit comments

Comments
 (0)