diff --git a/Spigot-API-Patches/Add-handshake-event-to-allow-plugins-to-handle-clien.patch b/Spigot-API-Patches/Add-handshake-event-to-allow-plugins-to-handle-clien.patch index 4140a3a524..39b067c254 100644 --- a/Spigot-API-Patches/Add-handshake-event-to-allow-plugins-to-handle-clien.patch +++ b/Spigot-API-Patches/Add-handshake-event-to-allow-plugins-to-handle-clien.patch @@ -37,6 +37,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + private static final HandlerList HANDLERS = new HandlerList(); + @NotNull private final String originalHandshake; ++ @NotNull private final String originalSocketAddressHostname; + private boolean cancelled; + @Nullable private String serverHostname; + @Nullable private String socketAddressHostname; @@ -50,10 +51,25 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @param originalHandshake the original handshake string + * @param cancelled if this event is enabled ++ * ++ * @deprecated in favour of {@link PlayerHandshakeEvent(String, String, boolean)} + */ ++ @Deprecated + public PlayerHandshakeEvent(@NotNull String originalHandshake, boolean cancelled) { ++ this(originalHandshake, "127.0.0.1", cancelled); ++ } ++ ++ /** ++ * Creates a new {@link PlayerHandshakeEvent}. ++ * ++ * @param originalHandshake the original handshake string ++ * @param originalSocketAddressHostname the original socket address hostname ++ * @param cancelled if this event is enabled ++ */ ++ public PlayerHandshakeEvent(@NotNull String originalHandshake, @NotNull String originalSocketAddressHostname, boolean cancelled) { + super(true); + this.originalHandshake = originalHandshake; ++ this.originalSocketAddressHostname = originalSocketAddressHostname; + this.cancelled = cancelled; + } + @@ -94,6 +110,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + /** ++ * Gets the original socket address hostname. ++ * ++ *
This does not include the port.
++ *In cases where this event is manually fired and the plugin wasn't updated yet, the default is {@code "127.0.0.1"}.
++ * ++ * @return the original socket address hostname ++ */ ++ @NotNull ++ public String getOriginalSocketAddressHostname() { ++ return this.originalSocketAddressHostname; ++ } ++ ++ /** + * Gets the server hostname string. + * + *This should not include the port.
diff --git a/Spigot-Server-Patches/Add-handshake-event-to-allow-plugins-to-handle-clien.patch b/Spigot-Server-Patches/Add-handshake-event-to-allow-plugins-to-handle-clien.patch index 3393c0c3c6..d0f73a3276 100644 --- a/Spigot-Server-Patches/Add-handshake-event-to-allow-plugins-to-handle-clien.patch +++ b/Spigot-Server-Patches/Add-handshake-event-to-allow-plugins-to-handle-clien.patch @@ -27,7 +27,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + boolean handledByEvent = false; + // Try and handle the handshake through the event + if (com.destroystokyo.paper.event.player.PlayerHandshakeEvent.getHandlerList().getRegisteredListeners().length != 0) { // Hello? Can you hear me? -+ com.destroystokyo.paper.event.player.PlayerHandshakeEvent event = new com.destroystokyo.paper.event.player.PlayerHandshakeEvent(packethandshakinginsetprotocol.hostname, !proxyLogicEnabled); ++ java.net.InetSocketAddress socketAddress = (java.net.InetSocketAddress) this.getNetworkManager().socketAddress; ++ com.destroystokyo.paper.event.player.PlayerHandshakeEvent event = new com.destroystokyo.paper.event.player.PlayerHandshakeEvent(packethandshakinginsetprotocol.hostname, socketAddress.getAddress().getHostAddress(), !proxyLogicEnabled); + if (event.callEvent()) { + // If we've failed somehow, let the client know so and go no further. + if (event.isFailed()) { @@ -38,7 +39,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + if (event.getServerHostname() != null) packethandshakinginsetprotocol.hostname = event.getServerHostname(); -+ if (event.getSocketAddressHostname() != null) 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(), socketAddress.getPort()); + this.getNetworkManager().spoofedUUID = event.getUniqueId(); + this.getNetworkManager().spoofedProfile = gson.fromJson(event.getPropertiesJson(), com.mojang.authlib.properties.Property[].class); + handledByEvent = true; // Hooray, we did it!