Search in sources :

Example 1 with PermissionManager

use of org.terasology.logic.permission.PermissionManager in project Terasology by MovingBlocks.

the class ConsoleImpl method clientHasPermission.

private boolean clientHasPermission(EntityRef callingClient, String requiredPermission) {
    Preconditions.checkNotNull(callingClient, "The calling client must not be null!");
    PermissionManager permissionManager = context.get(PermissionManager.class);
    boolean hasPermission = true;
    if (permissionManager != null && requiredPermission != null && !requiredPermission.equals(PermissionManager.NO_PERMISSION)) {
        hasPermission = false;
        ClientComponent clientComponent = callingClient.getComponent(ClientComponent.class);
        if (permissionManager.hasPermission(clientComponent.clientInfo, requiredPermission)) {
            hasPermission = true;
        }
    }
    return hasPermission;
}
Also used : PermissionManager(org.terasology.logic.permission.PermissionManager) ClientComponent(org.terasology.network.ClientComponent)

Aggregations

PermissionManager (org.terasology.logic.permission.PermissionManager)1 ClientComponent (org.terasology.network.ClientComponent)1