10
10
import net .minecraft .server .network .ServerHandshakeNetworkHandler ;
11
11
import net .minecraft .text .LiteralText ;
12
12
import net .minecraft .text .Text ;
13
- import one .oktw .interfaces .IClientConnection ;
14
- import one .oktw .interfaces . IHandshakeC2SPacket ;
13
+ import one .oktw .interfaces .BungeeClientConnection ;
14
+ import one .oktw .mixin . ClientConnectionAccessor ;
15
15
import org .spongepowered .asm .mixin .Final ;
16
16
import org .spongepowered .asm .mixin .Mixin ;
17
17
import org .spongepowered .asm .mixin .Shadow ;
@@ -29,22 +29,21 @@ public class ServerHandshakeNetworkHandlerMixin {
29
29
@ Final
30
30
private ClientConnection connection ;
31
31
32
- @ Inject (method = "onHandshake" , at = @ At (value = "HEAD" ), cancellable = true )
32
+ @ Inject (method = "onHandshake" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/server/network/ServerLoginNetworkHandler;<init>(Lnet/minecraft/server/MinecraftServer;Lnet/minecraft/network/ClientConnection;)V" ) )
33
33
private void onProcessHandshakeStart (HandshakeC2SPacket packet , CallbackInfo ci ) {
34
34
if (config .getBungeeCord () && packet .getIntendedState ().equals (NetworkState .LOGIN )) {
35
- String [] split = ((IHandshakeC2SPacket ) packet ).getAddress ().split ("\00 " );
35
+ String [] split = ((HandshakeC2SPacketAccessor ) packet ).getAddress ().split ("\00 " );
36
36
if (split .length == 3 || split .length == 4 ) {
37
- ((IHandshakeC2SPacket ) packet ).setAddress (split [0 ]);
38
- ((IClientConnection ) connection ).setRemoteAddress (new java .net .InetSocketAddress (split [1 ], ((java .net .InetSocketAddress ) connection .getAddress ()).getPort ()));
39
- ((IClientConnection ) connection ).setSpoofedUUID (UUIDTypeAdapter .fromString (split [2 ]));
37
+ ((ClientConnectionAccessor ) connection ).setAddress (new java .net .InetSocketAddress (split [1 ], ((java .net .InetSocketAddress ) connection .getAddress ()).getPort ()));
38
+ ((BungeeClientConnection ) connection ).setSpoofedUUID (UUIDTypeAdapter .fromString (split [2 ]));
39
+
40
+ if (split .length == 4 ) {
41
+ ((BungeeClientConnection ) connection ).setSpoofedProfile (gson .fromJson (split [3 ], Property [].class ));
42
+ }
40
43
} else {
41
44
Text disconnectMessage = new LiteralText ("If you wish to use IP forwarding, please enable it in your BungeeCord config as well!" );
42
45
connection .send (new LoginDisconnectS2CPacket (disconnectMessage ));
43
46
connection .disconnect (disconnectMessage );
44
- return ;
45
- }
46
- if (split .length == 4 ) {
47
- ((IClientConnection ) connection ).setSpoofedProfile (gson .fromJson (split [3 ], Property [].class ));
48
47
}
49
48
}
50
49
}
0 commit comments