fix: checkOverloadArgs not working correctly

This commit is contained in:
Chayapak 2025-03-19 17:25:19 +07:00
parent 0d0c8a2bce
commit a933653112
Signed by: ChomeNS
SSH key fingerprint: SHA256:0YoxhdyXsgbc0nfeB2N6FYE60mxMU7DS4uCUMaw2mvA
3 changed files with 4 additions and 8 deletions
build-number.txt
src/main/java/me/chayapak1/chomens_bot

View file

@ -1 +1 @@
1995
2005

View file

@ -3,7 +3,6 @@ package me.chayapak1.chomens_bot.command;
import me.chayapak1.chomens_bot.Bot;
import me.chayapak1.chomens_bot.data.player.PlayerEntry;
import me.chayapak1.chomens_bot.util.ColorUtilities;
import me.chayapak1.chomens_bot.util.StringUtilities;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.format.NamedTextColor;
@ -261,7 +260,9 @@ public class CommandContext {
final String quotesReplaced = joined.replaceAll("([\"'])(?:\\.|(?!\1).)*\1", "i");
final int count = StringUtilities.countCharacters(quotesReplaced, ' ');
final int count = quotesReplaced.isBlank() ?
0 :
quotesReplaced.split("\\s+").length;
if (count > maximumArgs) throw new CommandException(
Component.translatable(

View file

@ -9,11 +9,6 @@ import java.nio.charset.StandardCharsets;
import java.util.Map;
public class StringUtilities {
// https://stackoverflow.com/a/8910767/18518424
public static int countCharacters (String string, char character) {
return string.length() - string.replace(String.valueOf(character), "").length();
}
// https://stackoverflow.com/a/35148974/18518424
public static String truncateToFitUtf8ByteLength (String s, int maxBytes) {
if (s == null) {