Fix Paper's option to disable username validation

This commit is contained in:
Allink 2023-02-27 22:47:31 +00:00
parent 888600908c
commit 93e0794379
No known key found for this signature in database

View File

@ -0,0 +1,33 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Allink <arclicious@vivaldi.net>
Date: Mon, 27 Feb 2023 22:47:21 +0000
Subject: [PATCH] Fix Paper's option to disable username validation
diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
index a25306fe8a35bb70a490e6a0c01d0340bbc0d781..62a197a1dfbac8a1406316275e753a0f21978d5d 100644
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
@@ -237,14 +237,18 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
@Override
public void handleHello(ServerboundHelloPacket packet) {
Validate.validState(this.state == ServerLoginPacketListenerImpl.State.HELLO, "Unexpected hello packet", new Object[0]);
- Validate.validState(ServerLoginPacketListenerImpl.isValidUsername(packet.name()), "Invalid characters in username", new Object[0]);
- // Paper start - validate usernames
- if (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode() && io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.performUsernameValidation) {
- if (!this.iKnowThisMayNotBeTheBestIdeaButPleaseDisableUsernameValidation && !validateUsername(packet.name())) {
+ // Scissors start - Fix Paper's option to disable username validation
+ final boolean shouldVerifyUsernames = (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode()) || (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.performUsernameValidation && !this.iKnowThisMayNotBeTheBestIdeaButPleaseDisableUsernameValidation);
+
+ if (shouldVerifyUsernames) {
+ Validate.validState(ServerLoginPacketListenerImpl.isValidUsername(packet.name()), "Invalid characters in username", new Object[0]);
+ // Paper start - validate usernames
+ if (!validateUsername(packet.name())) {
ServerLoginPacketListenerImpl.this.disconnect("Failed to verify username!");
return;
}
}
+ // Scissors end - Fix Paper's option to disable username validation
// Paper end - validate usernames
GameProfile gameprofile = this.server.getSingleplayerProfile();