Add #183 - restricted servers

This commit is contained in:
md_5
2013-03-12 12:13:23 +11:00
parent f02d17c979
commit fea3642550
6 changed files with 40 additions and 11 deletions

View File

@@ -208,9 +208,10 @@ public abstract class ProxyServer
*
* @param name name of the server
* @param address connectable Minecraft address + port of the server
* @param restricted whether the server info restricted property will be set
* @return the constructed instance
*/
public abstract ServerInfo constructServerInfo(String name, InetSocketAddress address);
public abstract ServerInfo constructServerInfo(String name, InetSocketAddress address, boolean restricted);
/**
* Returns the console overlord for this proxy. Being the console, this

View File

@@ -31,6 +31,10 @@ public abstract class ServerInfo
* Players connected to a server defined by these properties.
*/
private final Collection<ProxiedPlayer> players = new ArrayList<>();
/**
* If set to true, users will need special permissions to view this server.
*/
private final boolean restricted;
/**
* Add a player to the internal set of this server.
@@ -79,4 +83,16 @@ public abstract class ServerInfo
* @param callback the callback to call when the count has been retrieved.
*/
public abstract void ping(Callback<ServerPing> callback);
/**
* Whether the player can access this server. It will only return false when
* the player has no permission and this server is restricted.
*
* @param player the player to check access for
* @return whether access is granted to this server
*/
public boolean canAccess(ProxiedPlayer player)
{
return restricted && player.hasPermission( "bungeecord.server." + name );
}
}