From ad45f316cdf341d93494a4284d3954c896e615e7 Mon Sep 17 00:00:00 2001 From: Connor Linfoot Date: Wed, 12 May 2021 09:57:54 +0100 Subject: [PATCH] Add raw address to AsyncPlayerPreLoginEvent (#5614) --- ...-address-to-AsyncPlayerPreLoginEvent.patch | 50 +++++++++++++++++++ ...-address-to-AsyncPlayerPreLoginEvent.patch | 25 ++++++++++ 2 files changed, 75 insertions(+) create mode 100644 Spigot-API-Patches/0297-Add-raw-address-to-AsyncPlayerPreLoginEvent.patch create mode 100644 Spigot-Server-Patches/0726-Add-raw-address-to-AsyncPlayerPreLoginEvent.patch diff --git a/Spigot-API-Patches/0297-Add-raw-address-to-AsyncPlayerPreLoginEvent.patch b/Spigot-API-Patches/0297-Add-raw-address-to-AsyncPlayerPreLoginEvent.patch new file mode 100644 index 000000000..58db0a8a2 --- /dev/null +++ b/Spigot-API-Patches/0297-Add-raw-address-to-AsyncPlayerPreLoginEvent.patch @@ -0,0 +1,50 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Connor Linfoot +Date: Wed, 12 May 2021 08:09:19 +0100 +Subject: [PATCH] Add raw address to AsyncPlayerPreLoginEvent + + +diff --git a/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java b/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java +index c9af02b0f62b3d18da1e91d1ea02ce0864fc60b9..77aefda5aac4602bf5bf71c29600e7450defdd4e 100644 +--- a/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java ++++ b/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java +@@ -20,6 +20,7 @@ public class AsyncPlayerPreLoginEvent extends Event { + private net.kyori.adventure.text.Component message; // Paper + //private String name; // Paper - Not used anymore + private final InetAddress ipAddress; ++ private final InetAddress rawAddress; // Paper + //private UUID uniqueId; // Paper - Not used anymore + + @Deprecated +@@ -49,7 +50,23 @@ public class AsyncPlayerPreLoginEvent extends Event { + this.profile = profile; + } + ++ // Paper Start ++ /** ++ * Gets the raw address of the player logging in ++ * @return The address ++ */ ++ @NotNull ++ public InetAddress getRawAddress() { ++ return rawAddress; ++ } ++ // Paper end ++ ++ @Deprecated + public AsyncPlayerPreLoginEvent(@NotNull final String name, @NotNull final InetAddress ipAddress, @NotNull final UUID uniqueId, @NotNull PlayerProfile profile) { ++ this(name, ipAddress, ipAddress, uniqueId, profile); ++ } ++ ++ public AsyncPlayerPreLoginEvent(@NotNull final String name, @NotNull final InetAddress ipAddress, @NotNull final InetAddress rawAddress, @NotNull final UUID uniqueId, @NotNull PlayerProfile profile) { + super(true); + this.profile = profile; + // Paper end +@@ -57,6 +74,7 @@ public class AsyncPlayerPreLoginEvent extends Event { + this.message = net.kyori.adventure.text.Component.empty(); // Paper + //this.name = name; // Paper - Not used anymore + this.ipAddress = ipAddress; ++ this.rawAddress = rawAddress; // Paper + //this.uniqueId = uniqueId; // Paper - Not used anymore + } + diff --git a/Spigot-Server-Patches/0726-Add-raw-address-to-AsyncPlayerPreLoginEvent.patch b/Spigot-Server-Patches/0726-Add-raw-address-to-AsyncPlayerPreLoginEvent.patch new file mode 100644 index 000000000..f946246fe --- /dev/null +++ b/Spigot-Server-Patches/0726-Add-raw-address-to-AsyncPlayerPreLoginEvent.patch @@ -0,0 +1,25 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Connor Linfoot +Date: Wed, 12 May 2021 08:09:19 +0100 +Subject: [PATCH] Add raw address to AsyncPlayerPreLoginEvent + + +diff --git a/src/main/java/net/minecraft/server/network/LoginListener.java b/src/main/java/net/minecraft/server/network/LoginListener.java +index c67b94840e4c967baebf6eb351df15f0e4ead4be..f54af7cabc6b4e062948dc97e577e7fe04b5add4 100644 +--- a/src/main/java/net/minecraft/server/network/LoginListener.java ++++ b/src/main/java/net/minecraft/server/network/LoginListener.java +@@ -327,12 +327,13 @@ public class LoginListener implements PacketLoginInListener { + // Paper end + String playerName = i.getName(); + java.net.InetAddress address = ((java.net.InetSocketAddress) networkManager.getSocketAddress()).getAddress(); ++ java.net.InetAddress rawAddress = ((java.net.InetSocketAddress) networkManager.getRawAddress()).getAddress(); // Paper + java.util.UUID uniqueId = i.getId(); + final org.bukkit.craftbukkit.CraftServer server = LoginListener.this.server.server; + + // Paper start + PlayerProfile profile = CraftPlayerProfile.asBukkitMirror(getGameProfile()); +- AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address, uniqueId, profile); ++ AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address, rawAddress, uniqueId, profile); + server.getPluginManager().callEvent(asyncEvent); + profile = asyncEvent.getPlayerProfile(); + profile.complete(true);