fix: highly experimental (and hacky!) patch for kick exploit

This commit is contained in:
amyavi 2024-09-29 12:44:42 -03:00
parent 39feb26c93
commit 0e2428ed2e
No known key found for this signature in database

View file

@ -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" -> {