Allow Bungee to pass through UUIDs. This will be added to bungee in a few days, so people get a chance to update Spigot first.

This commit is contained in:
md_5 2013-12-16 22:39:18 +11:00
parent de92a23d18
commit 154239b0fb

View File

@ -1,4 +1,4 @@
From 731b79cac5a62b1916cec175dddb9d7ab821e44a Mon Sep 17 00:00:00 2001
From 6db94f8d995eb97196a6f8569ca80fc719ae9344 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
@ -6,40 +6,71 @@ 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 b96e2ef..251e510 100644
index b96e2ef..fe2098e 100644
--- a/src/main/java/net/minecraft/server/HandshakeListener.java
+++ b/src/main/java/net/minecraft/server/HandshakeListener.java
@@ -28,6 +28,15 @@ public class HandshakeListener implements PacketHandshakingInListener {
@@ -28,6 +28,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) {
+ 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..42e6311 100644
index 8f829bb..4907a62 100644
--- a/src/main/java/net/minecraft/server/NetworkManager.java
+++ b/src/main/java/net/minecraft/server/NetworkManager.java
@@ -34,7 +34,7 @@ public class NetworkManager extends SimpleChannelInboundHandler {
@@ -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;
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
index 801b071..3ed1c29 100644
index 6e32691..acd5567 100644
--- a/src/main/java/org/spigotmc/SpigotConfig.java
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
@@ -187,4 +187,14 @@ public class SpigotConfig