#2572: Add additional APIs regarding server restriction
This commit is contained in:
parent
a12bb4cead
commit
4fa1d82b81
@ -43,6 +43,22 @@ public interface ServerInfo
|
||||
*/
|
||||
String getMotd();
|
||||
|
||||
/**
|
||||
* Whether this server is restricted and therefore only players with the
|
||||
* given permission can access it.
|
||||
*
|
||||
* @return if restricted
|
||||
*/
|
||||
boolean isRestricted();
|
||||
|
||||
/**
|
||||
* Get the permission required to access this server. Only enforced when the
|
||||
* server is restricted.
|
||||
*
|
||||
* @return access permission
|
||||
*/
|
||||
String getPermission();
|
||||
|
||||
/**
|
||||
* Whether the player can access this server. It will only return false when
|
||||
* the player has no permission and this server is restricted.
|
||||
|
@ -38,11 +38,23 @@ public class ServerConnectRequestTest
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAccess(CommandSender sender)
|
||||
public boolean isRestricted()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAccess(CommandSender sender)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendData(String channel, byte[] data)
|
||||
{
|
||||
|
@ -69,11 +69,17 @@ public class BungeeServerInfo implements ServerInfo
|
||||
return Collections.unmodifiableCollection( new HashSet<>( players ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission()
|
||||
{
|
||||
return "bungeecord.server." + name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAccess(CommandSender player)
|
||||
{
|
||||
Preconditions.checkNotNull( player, "player" );
|
||||
return !restricted || player.hasPermission( "bungeecord.server." + name );
|
||||
return !restricted || player.hasPermission( getPermission() );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user