mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-02 17:32:03 +01:00
28 lines
908 B
Diff
28 lines
908 B
Diff
--- a/net/minecraft/util/StringUtil.java
|
|
+++ b/net/minecraft/util/StringUtil.java
|
|
@@ -67,6 +67,25 @@
|
|
return name.length() <= 16 && name.chars().filter(c -> c <= 32 || c >= 127).findAny().isEmpty();
|
|
}
|
|
|
|
+ // 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
|
|
+
|
|
public static String filterText(String string) {
|
|
return filterText(string, false);
|
|
}
|