2013-09-22 11:16:15 +02:00
From c0dda8d1d5bd1dc0f9b9009213437584c1717cd9 Mon Sep 17 00:00:00 2001
2013-03-23 01:15:28 +01:00
From: md_5 <md_5@live.com.au>
Date: Sat, 23 Mar 2013 11:15:11 +1100
Subject: [PATCH] BungeeCord Support
- Allows BungeeCord to set the players real IP address very early in the login process, so that the BungeeCord proxy IP is never even seen by a plugin.
diff --git a/src/main/java/net/minecraft/server/PendingConnection.java b/src/main/java/net/minecraft/server/PendingConnection.java
2013-09-21 05:39:32 +02:00
index 6ffc927..8f1c214 100644
2013-03-23 01:15:28 +01:00
--- a/src/main/java/net/minecraft/server/PendingConnection.java
+++ b/src/main/java/net/minecraft/server/PendingConnection.java
2013-09-21 05:39:32 +02:00
@@ -236,4 +236,17 @@ public class PendingConnection extends Connection {
2013-03-23 01:15:28 +01:00
static boolean a(PendingConnection pendingconnection, boolean flag) {
return pendingconnection.h = flag;
}
+
+ // Spigot start
+ @Override
+ public void a(Packet250CustomPayload pcp) {
2013-06-20 11:37:15 +02:00
+ if (pcp.tag.equals("BungeeCord") && org.spigotmc.SpigotConfig.bungee && org.spigotmc.SpigotConfig.bungeeAddresses.contains(getSocket().getInetAddress().getHostAddress())) {
2013-03-23 01:15:28 +01:00
+ com.google.common.io.ByteArrayDataInput in = com.google.common.io.ByteStreams.newDataInput(pcp.data);
+ String subTag = in.readUTF();
+ if (subTag.equals("Login")) {
+ networkManager.setSocketAddress(new java.net.InetSocketAddress(in.readUTF(), in.readInt()));
+ }
+ }
+ }
+ // Spigot end
}
2013-04-25 01:42:40 +02:00
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
2013-09-12 02:17:46 +02:00
index 5dafeaf..a85fc5b 100644
2013-04-25 01:42:40 +02:00
--- a/src/main/java/net/minecraft/server/PlayerList.java
+++ b/src/main/java/net/minecraft/server/PlayerList.java
2013-09-12 02:17:46 +02:00
@@ -296,7 +296,7 @@ public abstract class PlayerList {
2013-04-25 01:42:40 +02:00
// depending on the outcome.
2013-07-02 05:03:56 +02:00
EntityPlayer entity = new EntityPlayer(this.server, this.server.getWorldServer(0), s, this.server.O() ? new DemoPlayerInteractManager(this.server.getWorldServer(0)) : new PlayerInteractManager(this.server.getWorldServer(0)));
2013-04-25 01:42:40 +02:00
Player player = entity.getBukkitEntity();
- PlayerLoginEvent event = new PlayerLoginEvent(player, hostname, pendingconnection.getSocket().getInetAddress());
2013-05-21 12:45:44 +02:00
+ PlayerLoginEvent event = new PlayerLoginEvent(player, hostname, ((java.net.InetSocketAddress) pendingconnection.networkManager.getSocketAddress()).getAddress(), pendingconnection.getSocket().getInetAddress()); // Spigot
2013-04-25 01:42:40 +02:00
SocketAddress socketaddress = pendingconnection.networkManager.getSocketAddress();
diff --git a/src/main/java/net/minecraft/server/ThreadLoginVerifier.java b/src/main/java/net/minecraft/server/ThreadLoginVerifier.java
2013-07-02 05:03:56 +02:00
index f87ebf9..f5032be 100644
2013-04-25 01:42:40 +02:00
--- a/src/main/java/net/minecraft/server/ThreadLoginVerifier.java
+++ b/src/main/java/net/minecraft/server/ThreadLoginVerifier.java
@@ -45,11 +45,11 @@ class ThreadLoginVerifier extends Thread {
return;
}
- AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(PendingConnection.d(this.pendingConnection), this.pendingConnection.getSocket().getInetAddress());
+ AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(PendingConnection.d(this.pendingConnection), ((java.net.InetSocketAddress) this.pendingConnection.networkManager.getSocketAddress()).getAddress()); // Spigot
this.server.getPluginManager().callEvent(asyncEvent);
if (PlayerPreLoginEvent.getHandlerList().getRegisteredListeners().length != 0) {
- final PlayerPreLoginEvent event = new PlayerPreLoginEvent(PendingConnection.d(this.pendingConnection), this.pendingConnection.getSocket().getInetAddress());
+ final PlayerPreLoginEvent event = new PlayerPreLoginEvent(PendingConnection.d(this.pendingConnection), ((java.net.InetSocketAddress) this.pendingConnection.networkManager.getSocketAddress()).getAddress()); // Spigot
if (asyncEvent.getResult() != PlayerPreLoginEvent.Result.ALLOWED) {
event.disallow(asyncEvent.getResult(), asyncEvent.getKickMessage());
}
2013-05-14 13:14:43 +02:00
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
2013-09-20 03:46:45 +02:00
index 20be022..e242f7d 100644
2013-05-14 13:14:43 +02:00
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
2013-08-03 10:45:50 +02:00
@@ -1077,6 +1077,11 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
2013-06-02 07:22:22 +02:00
// Spigot start
2013-08-03 11:59:46 +02:00
private final Player.Spigot spigot = new Player.Spigot()
2013-06-02 07:22:22 +02:00
{
+ @Override
+ public InetSocketAddress getRawAddress()
+ {
+ return ( getHandle().playerConnection == null ) ? null : (InetSocketAddress) getHandle().playerConnection.networkManager.getSocket().getRemoteSocketAddress();
+ }
};
2013-05-14 13:14:43 +02:00
2013-08-03 11:59:46 +02:00
public Player.Spigot spigot()
2013-06-20 11:37:15 +02:00
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
2013-09-22 11:16:15 +02:00
index d3e99eb..eaf1b91 100644
2013-06-20 11:37:15 +02:00
--- a/src/main/java/org/spigotmc/SpigotConfig.java
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
@@ -7,6 +7,7 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
2013-09-22 11:16:15 +02:00
@@ -201,4 +202,14 @@ public class SpigotConfig
2013-06-22 06:35:20 +02:00
nettyThreads = getInt( "settings.netty-threads", 3 );
2013-06-20 11:37:15 +02:00
}
+ public static List<String> bungeeAddresses = Arrays.asList( new String[]
+ {
+ "127.0.0.1"
+ } );
+ public static boolean bungee = true;
2013-06-21 10:57:20 +02:00
+ private static void bungee()
2013-06-20 11:37:15 +02:00
+ {
2013-06-22 07:48:42 +02:00
+ bungeeAddresses = getList( "settings.bungeecord-addresses", bungeeAddresses );
2013-06-20 11:37:15 +02:00
+ bungee = getBoolean( "settings.bungeecord", true );
+ }
}
2013-03-23 01:15:28 +01:00
--
2013-06-02 07:15:15 +02:00
1.8.1.2
2013-03-23 01:15:28 +01:00