Provide option to disable username validation (Closes #7250) (#7254)

This commit is contained in:
Shane Freeder 2022-01-02 12:51:22 +00:00
parent ac54c26f5e
commit ffa0464d81

View file

@ -4,6 +4,23 @@ Date: Sat, 1 Jan 2022 05:19:37 -0800
Subject: [PATCH] Validate usernames Subject: [PATCH] Validate usernames
diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
@@ -0,0 +0,0 @@ public class PaperConfig {
set("settings.unsupported-settings.allow-tnt-duplication", null);
}
+ public static boolean performUsernameValidation;
+ private static void performUsernameValidation() {
+ performUsernameValidation = getBoolean("settings.unsupported-settings.perform-username-validation", true);
+ }
+
+
public static int playerAutoSaveRate = -1;
public static int maxPlayerAutoSavePerTick = 10;
private static void playerAutoSaveRate() {
diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java --- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
@ -37,7 +54,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
Validate.validState(this.state == ServerLoginPacketListenerImpl.State.HELLO, "Unexpected hello packet", new Object[0]); Validate.validState(this.state == ServerLoginPacketListenerImpl.State.HELLO, "Unexpected hello packet", new Object[0]);
this.gameProfile = packet.getGameProfile(); this.gameProfile = packet.getGameProfile();
+ // Paper start - validate usernames + // Paper start - validate usernames
+ if (com.destroystokyo.paper.PaperConfig.isProxyOnlineMode()) { + if (com.destroystokyo.paper.PaperConfig.isProxyOnlineMode() && com.destroystokyo.paper.PaperConfig.performUsernameValidation) {
+ if (!validateUsername(this.gameProfile.getName())) { + if (!validateUsername(this.gameProfile.getName())) {
+ ServerLoginPacketListenerImpl.this.disconnect("Failed to verify username!"); + ServerLoginPacketListenerImpl.this.disconnect("Failed to verify username!");
+ return; + return;