2014-04-02 07:00:58 +00:00
From 30e848bc66d5249c518ef64af720b70ac09b15aa Mon Sep 17 00:00:00 2001
2013-12-01 07:18:51 +00:00
From: md_5 <md_5@live.com.au>
Date: Sun, 1 Dec 2013 18:18:41 +1100
Subject: [PATCH] BungeeCord Support
Provides support for IP forwarding via BungeeCord.
diff --git a/src/main/java/net/minecraft/server/HandshakeListener.java b/src/main/java/net/minecraft/server/HandshakeListener.java
2014-03-23 00:06:43 +00:00
index b80a760..42539b4 100644
2013-12-01 07:18:51 +00:00
--- a/src/main/java/net/minecraft/server/HandshakeListener.java
+++ b/src/main/java/net/minecraft/server/HandshakeListener.java
2014-03-14 21:46:24 +00:00
@@ -73,6 +73,22 @@ public class HandshakeListener implements PacketHandshakingInListener {
2014-03-23 00:06:43 +00:00
this.b.close(chatcomponenttext);
2013-12-01 07:18:51 +00:00
} else {
this.b.a((PacketListener) (new LoginListener(this.a, this.b)));
+ // Spigot Start
+ if (org.spigotmc.SpigotConfig.bungee) {
+ String[] split = packethandshakinginsetprotocol.b.split("\00");
2014-03-14 21:46:24 +00:00
+ if ( split.length == 3 ) {
2013-12-01 07:18:51 +00:00
+ packethandshakinginsetprotocol.b = split[0];
2014-03-23 00:06:43 +00:00
+ b.n = new java.net.InetSocketAddress(split[1], ((java.net.InetSocketAddress) b.getSocketAddress()).getPort());
2013-12-16 11:39:18 +00:00
+ b.spoofedUUID = split[2];
2014-03-14 21:46:24 +00:00
+ } else
+ {
+ chatcomponenttext = new ChatComponentText("If you wish to use IP forwarding, please enable it in your BungeeCord config as well!");
+ this.b.handle(new PacketLoginOutDisconnect(chatcomponenttext), new GenericFutureListener[0]);
2014-03-23 00:06:43 +00:00
+ this.b.close(chatcomponenttext);
2014-03-14 21:46:24 +00:00
+ return;
2013-12-16 11:39:18 +00:00
+ }
2013-12-01 07:18:51 +00:00
+ }
+ // Spigot End
((LoginListener) this.b.getPacketListener()).hostname = packethandshakinginsetprotocol.b + ":" + packethandshakinginsetprotocol.c; // CraftBukkit - set hostname
}
break;
2013-12-16 11:39:18 +00:00
diff --git a/src/main/java/net/minecraft/server/LoginListener.java b/src/main/java/net/minecraft/server/LoginListener.java
2014-03-23 00:06:43 +00:00
index dddd9aa..efba029 100644
2013-12-16 11:39:18 +00:00
--- a/src/main/java/net/minecraft/server/LoginListener.java
+++ b/src/main/java/net/minecraft/server/LoginListener.java
@@ -61,9 +61,18 @@ public class LoginListener implements PacketLoginInListener {
public void c() {
if (!this.i.isComplete()) {
- UUID uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + this.i.getName()).getBytes(Charsets.UTF_8));
-
- this.i = new GameProfile(uuid.toString().replaceAll("-", ""), this.i.getName());
+ // Spigot Start
+ String uuid;
+ if ( networkManager.spoofedUUID != null )
+ {
+ uuid = networkManager.spoofedUUID;
+ } else
+ {
+ uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + this.i.getName()).getBytes(Charsets.UTF_8)).toString().replaceAll("-", "");
+ }
+
+ this.i = new GameProfile(uuid, this.i.getName());
+ // Spigot End
}
2014-03-23 00:06:43 +00:00
// CraftBukkit start - fire PlayerLoginEvent
2013-12-01 07:18:51 +00:00
diff --git a/src/main/java/net/minecraft/server/NetworkManager.java b/src/main/java/net/minecraft/server/NetworkManager.java
2014-03-23 00:06:43 +00:00
index 9ff1694..f6cca80 100644
2013-12-01 07:18:51 +00:00
--- a/src/main/java/net/minecraft/server/NetworkManager.java
+++ b/src/main/java/net/minecraft/server/NetworkManager.java
2014-03-23 00:06:43 +00:00
@@ -36,7 +36,8 @@ public class NetworkManager extends SimpleChannelInboundHandler {
private final Queue k = Queues.newConcurrentLinkedQueue();
private final Queue l = Queues.newConcurrentLinkedQueue();
private Channel m;
- private SocketAddress n;
+ public SocketAddress n; // Spigot
2013-12-16 11:39:18 +00:00
+ public String spoofedUUID; // Spigot
2014-03-23 00:06:43 +00:00
private PacketListener o;
private EnumProtocol p;
private IChatBaseComponent q;
@@ -196,4 +197,11 @@ public class NetworkManager extends SimpleChannelInboundHandler {
2014-01-16 22:46:50 +00:00
static Channel a(NetworkManager networkmanager) {
2014-03-23 00:06:43 +00:00
return networkmanager.m;
2014-01-16 22:46:50 +00:00
}
+
+ // Spigot Start
+ public SocketAddress getRawAddress()
+ {
2014-03-23 00:06:43 +00:00
+ return this.m.remoteAddress();
2014-01-16 22:46:50 +00:00
+ }
+ // Spigot End
}
2014-03-26 23:53:19 +00:00
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
index 385dc0a..0d6ffef 100644
--- a/src/main/java/net/minecraft/server/PlayerList.java
+++ b/src/main/java/net/minecraft/server/PlayerList.java
@@ -325,7 +325,7 @@ public abstract class PlayerList {
EntityPlayer entity = new EntityPlayer(this.server, this.server.getWorldServer(0), gameprofile, new PlayerInteractManager(this.server.getWorldServer(0)));
Player player = entity.getBukkitEntity();
- PlayerLoginEvent event = new PlayerLoginEvent(player, hostname, ((java.net.InetSocketAddress) socketaddress).getAddress());
+ PlayerLoginEvent event = new PlayerLoginEvent(player, hostname, ((java.net.InetSocketAddress) socketaddress).getAddress(), ((java.net.InetSocketAddress) loginlistener.networkManager.getRawAddress()).getAddress());
if (this.banByName.isBanned(gameprofile.getName())) {
BanEntry banentry = (BanEntry) this.banByName.getEntries().get(gameprofile.getName());
2014-01-16 22:46:50 +00:00
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
2014-04-02 06:54:35 +00:00
index b96c27a..10a91fa 100644
2014-01-16 22:46:50 +00:00
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
2014-04-02 06:54:35 +00:00
@@ -1260,6 +1260,12 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
2014-01-16 22:46:50 +00:00
{
@Override
+ public InetSocketAddress getRawAddress()
+ {
+ return (InetSocketAddress) getHandle().playerConnection.networkManager.getRawAddress();
+ }
+
+ @Override
public boolean getCollidesWithEntities()
{
return getHandle().collidesWithEntities;
2013-12-01 07:18:51 +00:00
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
2014-04-02 07:00:58 +00:00
index 2b499fe..8bfffa5 100644
2013-12-01 07:18:51 +00:00
--- a/src/main/java/org/spigotmc/SpigotConfig.java
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
2014-04-02 07:00:58 +00:00
@@ -192,4 +192,14 @@ public class SpigotConfig
2013-12-01 07:18:51 +00:00
commands.put( "restart", new RestartCommand( "restart" ) );
WatchdogThread.doStart( timeoutTime, restartOnCrash );
}
+
2013-12-11 00:25:32 +00:00
+ public static boolean bungee;
2013-12-01 07:18:51 +00:00
+ private static void bungee() {
2013-12-11 00:25:32 +00:00
+ if ( version < 4 )
+ {
+ set( "settings.bungeecord", false );
+ System.out.println( "Oudated config, disabling BungeeCord support!" );
+ }
+ bungee = getBoolean( "settings.bungeecord", false );
2013-12-01 07:18:51 +00:00
+ }
}
--
2014-04-02 06:54:35 +00:00
1.8.3.2
2013-12-01 07:18:51 +00:00