From 60b7d5ee0c7d18032e2a1f94f76795d53c590151 Mon Sep 17 00:00:00 2001 From: Camotoy <20743703+Camotoy@users.noreply.github.com> Date: Mon, 17 Jan 2022 22:52:47 -0500 Subject: [PATCH] Add unsupported field to disable username validation (#7350) * Add unsupported field to disable username validation * Add unsupported field to disable username validation --- patches/server/0841-Validate-usernames.patch | 14 +++++++++++--- ...d-getHostname-to-AsyncPlayerPreLoginEvent.patch | 4 ++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/patches/server/0841-Validate-usernames.patch b/patches/server/0841-Validate-usernames.patch index e26aff06d4..2b31764c53 100644 --- a/patches/server/0841-Validate-usernames.patch +++ b/patches/server/0841-Validate-usernames.patch @@ -22,10 +22,18 @@ index d5aa95846e7f52108a03e3731023527281b21d73..1d3cc8836d2ccbec4a8660f86501be35 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 -index 33a29890435d6065a2cc4f8e8bf8209c01d5d114..462d8c36166c63a4dc8fa74ac7f82859e6f4b83a 100644 +index 33a29890435d6065a2cc4f8e8bf8209c01d5d114..bb70d2b4d284727aa5dc88dd99534d09c2e38657 100644 --- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -@@ -230,10 +230,38 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener +@@ -65,6 +65,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener + private ServerPlayer delayedAcceptPlayer; + public String hostname = ""; // CraftBukkit - add field + private int velocityLoginMessageId = -1; // Paper - Velocity support ++ public boolean iKnowThisMayNotBeTheBestIdeaButPleaseDisableUsernameValidation = false; // Paper - username validation overriding + + public ServerLoginPacketListenerImpl(MinecraftServer server, Connection connection) { + this.state = ServerLoginPacketListenerImpl.State.HELLO; +@@ -230,10 +231,38 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener // Paper end } @@ -55,7 +63,7 @@ index 33a29890435d6065a2cc4f8e8bf8209c01d5d114..462d8c36166c63a4dc8fa74ac7f82859 this.gameProfile = packet.getGameProfile(); + // Paper start - validate usernames + if (com.destroystokyo.paper.PaperConfig.isProxyOnlineMode() && com.destroystokyo.paper.PaperConfig.performUsernameValidation) { -+ if (!validateUsername(this.gameProfile.getName())) { ++ if (!this.iKnowThisMayNotBeTheBestIdeaButPleaseDisableUsernameValidation && !validateUsername(this.gameProfile.getName())) { + ServerLoginPacketListenerImpl.this.disconnect("Failed to verify username!"); + return; + } diff --git a/patches/server/0851-Added-getHostname-to-AsyncPlayerPreLoginEvent.patch b/patches/server/0851-Added-getHostname-to-AsyncPlayerPreLoginEvent.patch index cdd2a16b16..0a68f370f4 100644 --- a/patches/server/0851-Added-getHostname-to-AsyncPlayerPreLoginEvent.patch +++ b/patches/server/0851-Added-getHostname-to-AsyncPlayerPreLoginEvent.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Added getHostname to AsyncPlayerPreLoginEvent diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -index 462d8c36166c63a4dc8fa74ac7f82859e6f4b83a..60ba196e17df34c3ae2a9883e5d28830a2243517 100644 +index bb70d2b4d284727aa5dc88dd99534d09c2e38657..368e32bc12a1a09bf7309f299a1a72554947f43b 100644 --- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -@@ -391,7 +391,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener +@@ -392,7 +392,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener // Paper start PlayerProfile profile = CraftPlayerProfile.asBukkitMirror(ServerLoginPacketListenerImpl.this.gameProfile);