From 415d5860e45eb7cac8e9ac828288dc3789d9900a Mon Sep 17 00:00:00 2001 From: Joshua Rodriguez Date: Thu, 5 Feb 2015 20:53:52 -0800 Subject: [PATCH] Allow setting a connections uuid when in offline mode --- .../net/md_5/bungee/api/connection/PendingConnection.java | 5 +++++ .../java/net/md_5/bungee/connection/InitialHandler.java | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/api/src/main/java/net/md_5/bungee/api/connection/PendingConnection.java b/api/src/main/java/net/md_5/bungee/api/connection/PendingConnection.java index edf570de..cc511ef1 100644 --- a/api/src/main/java/net/md_5/bungee/api/connection/PendingConnection.java +++ b/api/src/main/java/net/md_5/bungee/api/connection/PendingConnection.java @@ -54,6 +54,11 @@ public interface PendingConnection extends Connection */ UUID getUniqueId(); + /** + * Set the connection's uuid + */ + void setUniqueId(UUID uuid); + /** * Get this connection's online mode. * diff --git a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java index e0283ee9..1e8a0f3b 100644 --- a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java +++ b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java @@ -571,6 +571,14 @@ public class InitialHandler extends PacketHandler implements PendingConnection this.onlineMode = onlineMode; } + @Override + public void setUniqueId(UUID uuid) + { + Preconditions.checkState( thisState == State.USERNAME, "Can only set uuid while state is username" ); + Preconditions.checkState( !onlineMode, "Can only set uuid when online mode is false" ); + this.uniqueId = uuid; + } + @Override public String getUUID() {