aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/api/0076-Expose-client-protocol-version-and-virtual-host.patch
blob: 292c3441aceb8ee17cf5500ecb455757c830aa90 (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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
From 0000000000000000000000000000000000000000 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 0000000000000000000000000000000000000000..7b2af1bd72dfbcf4e962a982940fc49b851aa04f
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/network/NetworkClient.java
@@ -0,0 +1,41 @@
+package com.destroystokyo.paper.network;
+
+import java.net.InetSocketAddress;
+
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Represents a client connected to the server.
+ */
+public interface NetworkClient {
+
+    /**
+     * Returns the socket address of the client.
+     *
+     * @return The client's socket address
+     */
+    @NotNull
+    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 7c97450f9fe2eebe03a1c30eb080d3d3624eefb8..f69d918381f706c21a55e2604564714cb74cba54 100644
--- a/src/main/java/org/bukkit/entity/Player.java
+++ b/src/main/java/org/bukkit/entity/Player.java
@@ -51,7 +51,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