Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JoshuaJB/e712df86104af51d05155ab87cf287ad to your computer and use it in GitHub Desktop.
Save JoshuaJB/e712df86104af51d05155ab87cf287ad to your computer and use it in GitHub Desktop.
Fix `Internal Exception: java.lang.IllegalStateException: Invalid characters in username` on offline servers with Spigot 1.19.
index 2db69f9d..2d0dd14c 100644
--- a/CraftBukkit-Patches/0030-Fire-PreLogin-Events-in-Offline-Mode.patch
+++ b/CraftBukkit-Patches/0030-Fire-PreLogin-Events-in-Offline-Mode.patch
@@ -55,6 +55,19 @@ index dbf5769bc..a780e30d3 100644
}
}
+@@ -235,9 +262,9 @@ public class LoginListener implements PacketLoginInListener {
+ }
+
+ public static boolean isValidUsername(String s) {
+- return s.chars().filter((i) -> {
+- return i <= 32 || i >= 127;
+- }).findAny().isEmpty();
++ // Joshua start
++ return true;
++ // Joshua end
+ }
+
+ @Override
@@ -280,40 +307,7 @@ public class LoginListener implements PacketLoginInListener {
return;
}
@JoshuaJB
Copy link
Author

JoshuaJB commented Jul 6, 2022

To apply this, run spigot's BuildTools.jar to get Spigot 1.19, cd Spigot, git apply disable-username-validation-craftbukkit-spigot.patch, and java -jar BuildTools.jar --dont-update. The resulting spigot-1.19.jar will then skip username validation, allowing for punctuation, unicode, spaces, etc in Minecraft servers in offline mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment