blob: 43458ac372b3d2b63a5a53a4a043c0cdf76347b3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
package moe.ymc.safelog.mixin;
import moe.ymc.safelog.SanitizedInetSocketAddress;
import net.minecraft.network.ClientConnection;
import net.minecraft.server.PlayerManager;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
@Mixin(PlayerManager.class)
public class PlayerManagerMixin {
@Redirect(
method = "onPlayerConnect",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/network/ClientConnection;getAddress()Ljava/net/SocketAddress;")
)
public SocketAddress modifyGetAddress(ClientConnection clientConnection) {
SocketAddress address = clientConnection.getAddress();
if (!(address instanceof InetSocketAddress inetAddress)) {
return address;
}
return new SanitizedInetSocketAddress(inetAddress.getAddress(), inetAddress.getPort());
}
}
|