papermc/CraftBukkit-Patches/0061-BungeeCord-Support.patch

147 lines
6.5 KiB
Diff
Raw Normal View History

2014-03-23 00:06:43 +00:00
From 801e2763278c04fdae00d5c825364fcc11d39ce9 Mon Sep 17 00:00:00 2001
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
--- a/src/main/java/net/minecraft/server/HandshakeListener.java
+++ b/src/main/java/net/minecraft/server/HandshakeListener.java
@@ -73,6 +73,22 @@ public class HandshakeListener implements PacketHandshakingInListener {
2014-03-23 00:06:43 +00:00
this.b.close(chatcomponenttext);
} else {
this.b.a((PacketListener) (new LoginListener(this.a, this.b)));
+ // Spigot Start
+ if (org.spigotmc.SpigotConfig.bungee) {
+ String[] split = packethandshakinginsetprotocol.b.split("\00");
+ if ( split.length == 3 ) {
+ 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());
+ b.spoofedUUID = split[2];
+ } 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);
+ return;
+ }
+ }
+ // Spigot End
((LoginListener) this.b.getPacketListener()).hostname = packethandshakinginsetprotocol.b + ":" + packethandshakinginsetprotocol.c; // CraftBukkit - set hostname
}
break;
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
--- 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
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
--- 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
+ 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
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
2014-03-23 00:06:43 +00:00
index d5903b7..3b626be 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-02-12 13:48:26 +00:00
@@ -1259,6 +1259,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;
2014-03-23 00:06:43 +00:00
diff --git a/src/main/java/org/spigotmc/RestartCommand.java b/src/main/java/org/spigotmc/RestartCommand.java
index a8840c9..922981e 100644
--- a/src/main/java/org/spigotmc/RestartCommand.java
+++ b/src/main/java/org/spigotmc/RestartCommand.java
@@ -44,7 +44,6 @@ public class RestartCommand extends Command
for ( EntityPlayer p : (List< EntityPlayer>) MinecraftServer.getServer().getPlayerList().players )
{
p.playerConnection.disconnect(SpigotConfig.restartMessage);
- p.playerConnection.networkManager.d();
}
// Give the socket a chance to send the packets
try
@@ -54,7 +53,7 @@ public class RestartCommand extends Command
{
}
// Close the socket so we can rebind with the new process
- MinecraftServer.getServer().ag().b();
+ MinecraftServer.getServer().ah().b();
// Give time for it to kick in
try
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
2014-01-31 20:42:29 +00:00
index 2ea1be7..08bd5ba 100644
--- a/src/main/java/org/spigotmc/SpigotConfig.java
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
2014-01-22 08:19:39 +00:00
@@ -181,4 +181,14 @@ public class SpigotConfig
commands.put( "restart", new RestartCommand( "restart" ) );
WatchdogThread.doStart( timeoutTime, restartOnCrash );
}
+
+ public static boolean bungee;
+ private static void bungee() {
+ if ( version < 4 )
+ {
+ set( "settings.bungeecord", false );
+ System.out.println( "Oudated config, disabling BungeeCord support!" );
+ }
+ bungee = getBoolean( "settings.bungeecord", false );
+ }
}
--
2014-03-23 00:06:43 +00:00
1.8.5.2.msysgit.0