From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Minecrell Date: Tue, 10 Oct 2017 18:44:42 +0200 Subject: [PATCH] Expose client protocol version and virtual host Add a NetworkClient interface that provides access to: - The socket address - The protocol version - The virtual host (the hostname/port the client used to connect to the server) diff --git a/src/main/java/com/destroystokyo/paper/network/NetworkClient.java b/src/main/java/com/destroystokyo/paper/network/NetworkClient.java new file mode 100644 index 0000000000000000000000000000000000000000..c84ce3fc874eea3d8f0b1cf5273996d9b4af6225 --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/network/NetworkClient.java @@ -0,0 +1,39 @@ +package com.destroystokyo.paper.network; + +import java.net.InetSocketAddress; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + +/** + * Represents a client connected to the server. + */ +@NullMarked +public interface NetworkClient { + + /** + * Returns the socket address of the client. + * + * @return The client's socket address + */ + InetSocketAddress getAddress(); + + /** + * Returns the protocol version of the client. + * + * @return The client's protocol version, or {@code -1} if unknown + * @see List of protocol + * version numbers + */ + int getProtocolVersion(); + + /** + * Returns the virtual host the client is connected to. + * + *

The virtual host refers to the hostname/port the client used to + * connect to the server.

+ * + * @return The client's virtual host, or {@code null} if unknown + */ + @Nullable InetSocketAddress getVirtualHost(); + +} diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java index 68f36afc6124f07d0e4bd75569252f3ebbb319a0..a605425b79131f885051d91bb57a30a695e0ce46 100644 --- a/src/main/java/org/bukkit/entity/Player.java +++ b/src/main/java/org/bukkit/entity/Player.java @@ -57,7 +57,7 @@ import org.jetbrains.annotations.Nullable; /** * Represents a player, connected or not */ -public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginMessageRecipient, net.kyori.adventure.identity.Identified, net.kyori.adventure.bossbar.BossBarViewer { // Paper +public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginMessageRecipient, net.kyori.adventure.identity.Identified, net.kyori.adventure.bossbar.BossBarViewer, com.destroystokyo.paper.network.NetworkClient { // Paper // Paper start @Override