diff --git a/src/main/java/pw/kaboom/extras/modules/server/ServerCommand.java b/src/main/java/pw/kaboom/extras/modules/server/ServerCommand.java index 9b1e08c..b77eed4 100644 --- a/src/main/java/pw/kaboom/extras/modules/server/ServerCommand.java +++ b/src/main/java/pw/kaboom/extras/modules/server/ServerCommand.java @@ -38,6 +38,19 @@ public final class ServerCommand implements Listener { return false; } + public static boolean checkValidUTF8(final String component) { + int len = component.length(); + + for (int i = 0; i < component.length(); i++) { + int c = component.charAt(i); + if (c == 0 || c >= 128) { + len += c >= 2048 ? 2 : 1; + } + } + + return len <= 65535; + } + private static String checkSelectors(final String[] arr) { final String[] args = Arrays.copyOfRange(arr, 1, arr.length); final String str = String.join(" ", args); @@ -77,6 +90,8 @@ public final class ServerCommand implements Listener { commandName = "/" + arr[1].toLowerCase(); } + if (!checkValidUTF8(command)) return "cancel"; + try { switch (commandName) { case "/minecraft:execute", "/execute" -> {