fix: checkOverloadArgs
not working correctly
This commit is contained in:
parent
0d0c8a2bce
commit
a933653112
3 changed files with 4 additions and 8 deletions
build-number.txt
src/main/java/me/chayapak1/chomens_bot
|
@ -1 +1 @@
|
||||||
1995
|
2005
|
|
@ -3,7 +3,6 @@ package me.chayapak1.chomens_bot.command;
|
||||||
import me.chayapak1.chomens_bot.Bot;
|
import me.chayapak1.chomens_bot.Bot;
|
||||||
import me.chayapak1.chomens_bot.data.player.PlayerEntry;
|
import me.chayapak1.chomens_bot.data.player.PlayerEntry;
|
||||||
import me.chayapak1.chomens_bot.util.ColorUtilities;
|
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.Component;
|
||||||
import net.kyori.adventure.text.event.ClickEvent;
|
import net.kyori.adventure.text.event.ClickEvent;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
@ -261,7 +260,9 @@ public class CommandContext {
|
||||||
|
|
||||||
final String quotesReplaced = joined.replaceAll("([\"'])(?:\\.|(?!\1).)*\1", "i");
|
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(
|
if (count > maximumArgs) throw new CommandException(
|
||||||
Component.translatable(
|
Component.translatable(
|
||||||
|
|
|
@ -9,11 +9,6 @@ import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class StringUtilities {
|
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
|
// https://stackoverflow.com/a/35148974/18518424
|
||||||
public static String truncateToFitUtf8ByteLength (String s, int maxBytes) {
|
public static String truncateToFitUtf8ByteLength (String s, int maxBytes) {
|
||||||
if (s == null) {
|
if (s == null) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue