From 05db99ce17aa2ad094c413254c0945e004afe326 Mon Sep 17 00:00:00 2001 From: md_5 Date: Tue, 21 May 2013 20:45:44 +1000 Subject: [PATCH] Add better APIs for bungee raw IP --- Bukkit-Patches/0007-BungeeCord-Support.patch | 70 ++++++++++++++++++- .../0031-BungeeCord-Support.patch | 6 +- 2 files changed, 71 insertions(+), 5 deletions(-) diff --git a/Bukkit-Patches/0007-BungeeCord-Support.patch b/Bukkit-Patches/0007-BungeeCord-Support.patch index d4d35f725..2fe89a95c 100644 --- a/Bukkit-Patches/0007-BungeeCord-Support.patch +++ b/Bukkit-Patches/0007-BungeeCord-Support.patch @@ -1,11 +1,11 @@ -From aec07f66117cb86522e8f507bbd6e53780eb1e36 Mon Sep 17 00:00:00 2001 +From 023a20f822b88403e7f6adae71f7386c70735176 Mon Sep 17 00:00:00 2001 From: md_5 Date: Tue, 14 May 2013 21:11:29 +1000 Subject: [PATCH] BungeeCord Support diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java -index dec2214..602ecef 100644 +index de42f2e..6493825 100644 --- a/src/main/java/org/bukkit/entity/Player.java +++ b/src/main/java/org/bukkit/entity/Player.java @@ -646,4 +646,13 @@ public interface Player extends HumanEntity, Conversable, CommandSender, Offline @@ -22,6 +22,72 @@ index dec2214..602ecef 100644 + public InetSocketAddress getRawAddress(); + // Spigot end } +diff --git a/src/main/java/org/bukkit/event/player/PlayerLoginEvent.java b/src/main/java/org/bukkit/event/player/PlayerLoginEvent.java +index 60c0875..dab3c5c 100644 +--- a/src/main/java/org/bukkit/event/player/PlayerLoginEvent.java ++++ b/src/main/java/org/bukkit/event/player/PlayerLoginEvent.java +@@ -14,6 +14,7 @@ public class PlayerLoginEvent extends PlayerEvent { + private final String hostname; + private Result result = Result.ALLOWED; + private String message = ""; ++ private final InetAddress realAddress; // Spigot + + /** + * @deprecated Address should be provided in other constructor +@@ -38,10 +39,17 @@ public class PlayerLoginEvent extends PlayerEvent { + * @param hostname The hostname that was used to connect to the server + * @param address The address the player used to connect, provided for timing issues + */ +- public PlayerLoginEvent(final Player player, final String hostname, final InetAddress address) { ++ public PlayerLoginEvent(final Player player, final String hostname, final InetAddress address, final InetAddress realAddress) { // Spigot + super(player); + this.hostname = hostname; + this.address = address; ++ // Spigot start ++ this.realAddress = address; ++ } ++ ++ public PlayerLoginEvent(final Player player, final String hostname, final InetAddress address) { ++ this(player, hostname, address, address); ++ // Spigot end + } + + /** +@@ -49,7 +57,7 @@ public class PlayerLoginEvent extends PlayerEvent { + */ + @Deprecated + public PlayerLoginEvent(final Player player, final Result result, final String message) { +- this(player, "", null, result, message); ++ this(player, "", null, result, message, null); // Spigot + } + + /** +@@ -61,12 +69,23 @@ public class PlayerLoginEvent extends PlayerEvent { + * @param result The result status for this event + * @param message The message to be displayed if result denies login + */ +- public PlayerLoginEvent(final Player player, String hostname, final InetAddress address, final Result result, final String message) { +- this(player, hostname, address); ++ public PlayerLoginEvent(final Player player, String hostname, final InetAddress address, final Result result, final String message, final InetAddress realAddress) { // Spigot ++ this(player, hostname, address, realAddress); // Spigot + this.result = result; + this.message = message; + } + ++ // Spigot start ++ /** ++ * Gets the connection address of this player, regardless of whether it has been spoofed or not. ++ * ++ * @return the player's connection address ++ */ ++ public InetAddress getRealAddress() { ++ return realAddress; ++ } ++ // Spigot end ++ + /** + * Gets the current result of the login, as an enum + * -- 1.8.2.1 diff --git a/CraftBukkit-Patches/0031-BungeeCord-Support.patch b/CraftBukkit-Patches/0031-BungeeCord-Support.patch index 823854b48..f599cb8c8 100644 --- a/CraftBukkit-Patches/0031-BungeeCord-Support.patch +++ b/CraftBukkit-Patches/0031-BungeeCord-Support.patch @@ -1,4 +1,4 @@ -From 391c4be8c84b3e1220a84b4878b2be67b143d62a Mon Sep 17 00:00:00 2001 +From 2f2271a64bb6770f9a7a3224d585e6dd18caf0c0 Mon Sep 17 00:00:00 2001 From: md_5 Date: Sat, 23 Mar 2013 11:15:11 +1100 Subject: [PATCH] BungeeCord Support @@ -28,7 +28,7 @@ index a945892..7ef9a6f 100644 + // Spigot end } diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java -index 5ccc7f0..cc9c3ba 100644 +index 5ccc7f0..6af611a 100644 --- a/src/main/java/net/minecraft/server/PlayerList.java +++ b/src/main/java/net/minecraft/server/PlayerList.java @@ -293,7 +293,7 @@ public abstract class PlayerList { @@ -36,7 +36,7 @@ index 5ccc7f0..cc9c3ba 100644 EntityPlayer entity = new EntityPlayer(this.server, this.server.getWorldServer(0), s, this.server.M() ? new DemoPlayerInteractManager(this.server.getWorldServer(0)) : new PlayerInteractManager(this.server.getWorldServer(0))); Player player = entity.getBukkitEntity(); - PlayerLoginEvent event = new PlayerLoginEvent(player, hostname, pendingconnection.getSocket().getInetAddress()); -+ PlayerLoginEvent event = new PlayerLoginEvent(player, hostname, ((java.net.InetSocketAddress) pendingconnection.networkManager.getSocketAddress()).getAddress()); // Spigot ++ PlayerLoginEvent event = new PlayerLoginEvent(player, hostname, ((java.net.InetSocketAddress) pendingconnection.networkManager.getSocketAddress()).getAddress(), pendingconnection.getSocket().getInetAddress()); // Spigot SocketAddress socketaddress = pendingconnection.networkManager.getSocketAddress();