geforkt von Mirrors/Paper
123 Zeilen
5.2 KiB
Diff
123 Zeilen
5.2 KiB
Diff
From 8ee5fd0371c74a972cf943018b8995dd650530ae 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
|
|
index 9533fd1..6098eb5 100644
|
|
--- a/src/main/java/net/minecraft/server/HandshakeListener.java
|
|
+++ b/src/main/java/net/minecraft/server/HandshakeListener.java
|
|
@@ -73,6 +73,19 @@ public class HandshakeListener implements PacketHandshakingInListener {
|
|
this.b.a((IChatBaseComponent) 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 == 2 || split.length == 3) {
|
|
+ packethandshakinginsetprotocol.b = split[0];
|
|
+ b.l = new java.net.InetSocketAddress(split[1], ((java.net.InetSocketAddress) b.getSocketAddress()).getPort());
|
|
+ }
|
|
+ if ( split.length == 3 )
|
|
+ {
|
|
+ b.spoofedUUID = split[2];
|
|
+ }
|
|
+ }
|
|
+ // 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
|
|
index 6beac82..aa06e92 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
|
|
}
|
|
|
|
// CraftBukkit start
|
|
diff --git a/src/main/java/net/minecraft/server/NetworkManager.java b/src/main/java/net/minecraft/server/NetworkManager.java
|
|
index 8f829bb..6b2fbb9 100644
|
|
--- a/src/main/java/net/minecraft/server/NetworkManager.java
|
|
+++ b/src/main/java/net/minecraft/server/NetworkManager.java
|
|
@@ -34,7 +34,8 @@ public class NetworkManager extends SimpleChannelInboundHandler {
|
|
private final Queue i = Queues.newConcurrentLinkedQueue();
|
|
private final Queue j = Queues.newConcurrentLinkedQueue();
|
|
private Channel k;
|
|
- private SocketAddress l;
|
|
+ public SocketAddress l; // Spigot
|
|
+ public String spoofedUUID; // Spigot
|
|
private PacketListener m;
|
|
private EnumProtocol n;
|
|
private IChatBaseComponent o;
|
|
@@ -195,4 +196,11 @@ public class NetworkManager extends SimpleChannelInboundHandler {
|
|
static Channel a(NetworkManager networkmanager) {
|
|
return networkmanager.k;
|
|
}
|
|
+
|
|
+ // Spigot Start
|
|
+ public SocketAddress getRawAddress()
|
|
+ {
|
|
+ return this.k.remoteAddress();
|
|
+ }
|
|
+ // Spigot End
|
|
}
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
index f8e43d1..7eb95e2 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
@@ -1261,6 +1261,12 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|
{
|
|
|
|
@Override
|
|
+ public InetSocketAddress getRawAddress()
|
|
+ {
|
|
+ return (InetSocketAddress) getHandle().playerConnection.networkManager.getRawAddress();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
public boolean getCollidesWithEntities()
|
|
{
|
|
return getHandle().collidesWithEntities;
|
|
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
|
|
index 2ea1be7..08bd5ba 100644
|
|
--- a/src/main/java/org/spigotmc/SpigotConfig.java
|
|
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
|
|
@@ -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 );
|
|
+ }
|
|
}
|
|
--
|
|
1.8.4.msysgit.0
|
|
|