Return a Users UUID as a UUID object whilst keeping support for returning as a String

This commit is contained in:
Keir Nellyer
2014-04-02 10:25:42 +01:00
committed by md_5
parent a4dd0dba88
commit 13848def72
5 changed files with 52 additions and 6 deletions

View File

@@ -2,6 +2,7 @@ package net.md_5.bungee;
import com.google.common.base.Joiner;
import java.net.InetSocketAddress;
import java.util.UUID;
/**
* Series of utility classes to perform various operations.
@@ -63,4 +64,15 @@ public class Util
{
return Joiner.on( separators ).join( objects );
}
/**
* Converts a String to a UUID
*
* @param uuid The string to be converted
* @return The result
*/
public static UUID getUUID(String uuid)
{
return UUID.fromString( uuid.substring( 0, 8 ) + "-" + uuid.substring( 8, 12 ) + "-" + uuid.substring( 12, 16 ) + "-" + uuid.substring( 16, 20 ) + "-" + uuid.substring( 20, 32 ) );
}
}

View File

@@ -1,6 +1,7 @@
package net.md_5.bungee.api.connection;
import java.net.InetSocketAddress;
import java.util.UUID;
import net.md_5.bungee.api.config.ListenerInfo;
/**
@@ -41,9 +42,18 @@ public interface PendingConnection extends Connection
* Get this connection's UUID, if set.
*
* @return the UUID
* @deprecated In favour of {@link #getUniqueId()}
*/
@Deprecated
String getUUID();
/**
* Get this connection's UUID, if set.
*
* @return the UUID
*/
UUID getUniqueId();
/**
* Get this connection's online mode.
*

View File

@@ -4,6 +4,7 @@ import net.md_5.bungee.api.Callback;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.tab.TabListHandler;
import java.util.UUID;
/**
* Represents a player who's connection is being connected to somewhere else,
@@ -117,6 +118,15 @@ public interface ProxiedPlayer extends Connection, CommandSender
* Get this connection's UUID, if set.
*
* @return the UUID
* @deprecated In favour of {@link #getUniqueId()}
*/
@Deprecated
String getUUID();
/**
* Get this connection's UUID, if set.
*
* @return the UUID
*/
UUID getUniqueId();
}