PaperMC/paper-server/patches/sources/net/minecraft/util/StringUtil.java.patch

29 lines
890 B
Diff
Raw Normal View History

2022-01-01 14:19:37 +01:00
--- a/net/minecraft/util/StringUtil.java
+++ b/net/minecraft/util/StringUtil.java
2024-12-13 20:30:07 +01:00
@@ -85,6 +_,25 @@
return stringBuilder.toString();
2022-01-01 14:19:37 +01:00
}
+ // Paper start - Username validation
+ public static boolean isReasonablePlayerName(final String name) {
+ if (name.isEmpty() || name.length() > 16) {
+ return false;
+ }
+
+ for (int i = 0, len = name.length(); i < len; ++i) {
+ final char c = name.charAt(i);
+ if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || (c == '_' || c == '.')) {
+ continue;
+ }
+
+ return false;
+ }
+
+ return true;
+ }
+ // Paper end - Username validation
+
2024-12-13 20:30:07 +01:00
public static boolean isWhitespace(int character) {
return Character.isWhitespace(character) || Character.isSpaceChar(character);
2022-01-01 14:19:37 +01:00
}