Add method to get a connected player via their UUID
This commit is contained in:
parent
18316eb5f8
commit
a642346a2c
@ -7,6 +7,7 @@ import java.io.File;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Logger;
|
||||
import lombok.Getter;
|
||||
import net.md_5.bungee.api.config.ConfigurationAdapter;
|
||||
@ -79,6 +80,14 @@ public abstract class ProxyServer
|
||||
*/
|
||||
public abstract ProxiedPlayer getPlayer(String name);
|
||||
|
||||
/**
|
||||
* Gets a connected player via their UUID
|
||||
*
|
||||
* @param uuid of the player
|
||||
* @return their player instance
|
||||
*/
|
||||
public abstract ProxiedPlayer getPlayer(UUID uuid);
|
||||
|
||||
/**
|
||||
* Return all servers registered to this proxy, keyed by name. Unlike the
|
||||
* methods in {@link ConfigurationAdapter#getServers()}, this will not
|
||||
|
@ -442,6 +442,26 @@ public class BungeeCord extends ProxyServer
|
||||
}
|
||||
}
|
||||
|
||||
public ProxiedPlayer getPlayer(UUID uuid)
|
||||
{
|
||||
connectionLock.readLock().lock();
|
||||
try
|
||||
{
|
||||
for ( ProxiedPlayer proxiedPlayer : connections.values() )
|
||||
{
|
||||
if ( proxiedPlayer.getUniqueId().equals( uuid ) )
|
||||
{
|
||||
return proxiedPlayer;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
} finally
|
||||
{
|
||||
connectionLock.readLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, ServerInfo> getServers()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user