mirror of
https://github.com/SpigotMC/BungeeCord.git
synced 2024-11-30 22:24:18 +01:00
#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();
|
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
|
* Whether the player can access this server. It will only return false when
|
||||||
* the player has no permission and this server is restricted.
|
* the player has no permission and this server is restricted.
|
||||||
|
@ -38,11 +38,23 @@ public class ServerConnectRequestTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canAccess(CommandSender sender)
|
public boolean isRestricted()
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPermission()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canAccess(CommandSender sender)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendData(String channel, byte[] data)
|
public void sendData(String channel, byte[] data)
|
||||||
{
|
{
|
||||||
|
@ -69,11 +69,17 @@ public class BungeeServerInfo implements ServerInfo
|
|||||||
return Collections.unmodifiableCollection( new HashSet<>( players ) );
|
return Collections.unmodifiableCollection( new HashSet<>( players ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPermission()
|
||||||
|
{
|
||||||
|
return "bungeecord.server." + name;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canAccess(CommandSender player)
|
public boolean canAccess(CommandSender player)
|
||||||
{
|
{
|
||||||
Preconditions.checkNotNull( player, "player" );
|
Preconditions.checkNotNull( player, "player" );
|
||||||
return !restricted || player.hasPermission( "bungeecord.server." + name );
|
return !restricted || player.hasPermission( getPermission() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user