PaperMC/Spigot-API-Patches/0072-Expose-client-protocol-version-and-virtual-host.patch
Aikar a8c28e1920
Initial Paper-API for Bukkit 1.13 Preview 4 - THIS IS NOT SERVER
This branch/commit is only useful to those who purely use a clean Bukkit/Spigot/Paper API
and does not use NMS/OBC references.

This will let you start updating your plugin to the latest 1.13 builds of Bukkit Preview (4 as of now)

Note that this release is not final!!! API breakages may occur!

It is up to you if you find use out of this work.
2018-07-14 21:53:22 -04:00

72 lines
2.4 KiB
Diff

From d40adbcb5398dc21486b6b6c8817d751fe9ced12 Mon Sep 17 00:00:00 2001
From: Minecrell <minecrell@minecrell.net>
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 00000000..9072e384
--- /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 javax.annotation.Nullable;
+
+/**
+ * Represents a client connected to the server.
+ */
+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 <a href="http://wiki.vg/Protocol_version_numbers">List of protocol
+ * version numbers</a>
+ */
+ int getProtocolVersion();
+
+ /**
+ * Returns the virtual host the client is connected to.
+ *
+ * <p>The virtual host refers to the hostname/port the client used to
+ * connect to the server.</p>
+ *
+ * @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 5c29c11e..60cdd620 100644
--- a/src/main/java/org/bukkit/entity/Player.java
+++ b/src/main/java/org/bukkit/entity/Player.java
@@ -31,7 +31,7 @@ import org.bukkit.scoreboard.Scoreboard;
/**
* Represents a player, connected or not
*/
-public interface Player extends HumanEntity, Conversable, CommandSender, OfflinePlayer, PluginMessageRecipient {
+public interface Player extends HumanEntity, Conversable, CommandSender, OfflinePlayer, PluginMessageRecipient, com.destroystokyo.paper.network.NetworkClient { // Paper - Extend NetworkClient
/**
* Gets the "friendly" name to display of this player. This may include
--
2.18.0