Add unsupported field to disable username validation (#7350)

* Add unsupported field to disable username validation

* Add unsupported field to disable username validation
This commit is contained in:
Camotoy 2022-01-17 22:52:47 -05:00
parent affb89f9a2
commit 756c3377ea

View file

@ -25,6 +25,14 @@ diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListene
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
@@ -0,0 +0,0 @@ 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;
@@ -0,0 +0,0 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener
// Paper end
}
@ -55,7 +63,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
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;
+ }