mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-15 05:41:51 +08:00
Add support for netty based socket addresses to fabric
Affects issues: - Possibly fixed #3065
This commit is contained in:
parent
439eb60f31
commit
4b33026a5f
@ -17,6 +17,8 @@
|
||||
package net.playeranalytics.plan.gathering.domain;
|
||||
|
||||
import com.djrapitops.plan.gathering.domain.PlatformPlayerData;
|
||||
import io.netty.channel.local.LocalAddress;
|
||||
import io.netty.channel.unix.DomainSocketAddress;
|
||||
import net.minecraft.server.dedicated.MinecraftDedicatedServer;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
|
||||
@ -76,9 +78,11 @@ public class FabricPlayerData implements PlatformPlayerData {
|
||||
SocketAddress socketAddress = player.networkHandler.getConnectionAddress();
|
||||
if (socketAddress instanceof InetSocketAddress inetSocketAddress) {
|
||||
return Optional.of(inetSocketAddress.getAddress());
|
||||
} else if (socketAddress instanceof UnixDomainSocketAddress) {
|
||||
} else if (socketAddress instanceof UnixDomainSocketAddress || socketAddress instanceof LocalAddress) {
|
||||
// These connections come from the same physical machine
|
||||
return Optional.of(InetAddress.getLocalHost());
|
||||
} else if (socketAddress instanceof DomainSocketAddress domainSocketAddress) {
|
||||
return Optional.of(InetAddress.getByName(domainSocketAddress.path()));
|
||||
}
|
||||
} catch (NoSuchMethodError | UnknownHostException e) {
|
||||
// Ignored
|
||||
|
Loading…
Reference in New Issue
Block a user