Emancipate more features to PlayerHandshakeEvent

* The hostname and socket address was not null when the event fired, but the event does not provide the value, the change allows plugins to use the old value.
* Since `proxyLogicEnabled` will be checked after the event fired, to check the config value will allow plugins to modify it during the event handling.

Signed-off-by: MiniDigger <admin@minidigger.me>
This commit is contained in:
cakoyo 2020-12-16 21:43:09 +01:00 committed by MiniDigger
parent 3fdeba1f5c
commit ede41fe163

View file

@ -6,7 +6,7 @@ Subject: [PATCH] Add handshake event to allow plugins to handle client
diff --git a/src/main/java/net/minecraft/server/HandshakeListener.java b/src/main/java/net/minecraft/server/HandshakeListener.java diff --git a/src/main/java/net/minecraft/server/HandshakeListener.java b/src/main/java/net/minecraft/server/HandshakeListener.java
index 69fd0a7b230c6f6eb46a43477465f77b265cc3c9..396c3f824968512e55987fd98d82d10e9cad6903 100644 index 69fd0a7b230c6f6eb46a43477465f77b265cc3c9..4de8646811f25b6217cffcd31fc14bcf79151b1a 100644
--- a/src/main/java/net/minecraft/server/HandshakeListener.java --- a/src/main/java/net/minecraft/server/HandshakeListener.java
+++ b/src/main/java/net/minecraft/server/HandshakeListener.java +++ b/src/main/java/net/minecraft/server/HandshakeListener.java
@@ -14,7 +14,7 @@ public class HandshakeListener implements PacketHandshakingInListener { @@ -14,7 +14,7 @@ public class HandshakeListener implements PacketHandshakingInListener {
@ -37,8 +37,8 @@ index 69fd0a7b230c6f6eb46a43477465f77b265cc3c9..396c3f824968512e55987fd98d82d10e
+ return; + return;
+ } + }
+ +
+ packethandshakinginsetprotocol.hostname = event.getServerHostname(); + if (event.getServerHostname() != null) packethandshakinginsetprotocol.hostname = event.getServerHostname();
+ this.getNetworkManager().socketAddress = new java.net.InetSocketAddress(event.getSocketAddressHostname(), ((java.net.InetSocketAddress) this.getNetworkManager().getSocketAddress()).getPort()); + if (event.getSocketAddressHostname() != null) this.getNetworkManager().socketAddress = new java.net.InetSocketAddress(event.getSocketAddressHostname(), ((java.net.InetSocketAddress) this.getNetworkManager().getSocketAddress()).getPort());
+ this.getNetworkManager().spoofedUUID = event.getUniqueId(); + this.getNetworkManager().spoofedUUID = event.getUniqueId();
+ this.getNetworkManager().spoofedProfile = gson.fromJson(event.getPropertiesJson(), com.mojang.authlib.properties.Property[].class); + this.getNetworkManager().spoofedProfile = gson.fromJson(event.getPropertiesJson(), com.mojang.authlib.properties.Property[].class);
+ handledByEvent = true; // Hooray, we did it! + handledByEvent = true; // Hooray, we did it!