Java Code Examples for net.luckperms.api.query.QueryOptions#Builder

The following examples show how to use net.luckperms.api.query.QueryOptions#Builder . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BukkitContextManager.java    From LuckPerms with MIT License 5 votes vote down vote up
@Override
public QueryOptions formQueryOptions(Player subject, ImmutableContextSet contextSet) {
    QueryOptions.Builder queryOptions = this.plugin.getConfiguration().get(ConfigKeys.GLOBAL_QUERY_OPTIONS).toBuilder();
    if (subject.isOp()) {
        queryOptions.option(OP_OPTION, true);
    }

    return queryOptions.context(contextSet).build();
}
 
Example 2
Source File: LuckPermsVaultChat.java    From LuckPerms with MIT License 5 votes vote down vote up
private QueryOptions createQueryOptionsForWorldSet(String world) {
    ImmutableContextSet.Builder context = new ImmutableContextSetImpl.BuilderImpl();
    if (world != null && !world.equals("") && !world.equalsIgnoreCase("global")) {
        context.add(DefaultContextKeys.WORLD_KEY, world.toLowerCase());
    }
    context.add(DefaultContextKeys.SERVER_KEY, this.vaultPermission.getVaultServer());

    QueryOptions.Builder builder = QueryOptionsImpl.DEFAULT_CONTEXTUAL.toBuilder();
    builder.context(context.build());
    builder.flag(Flag.INCLUDE_NODES_WITHOUT_SERVER_CONTEXT, this.vaultPermission.isIncludeGlobal());
    return builder.build();
}
 
Example 3
Source File: NukkitContextManager.java    From LuckPerms with MIT License 5 votes vote down vote up
@Override
public QueryOptions formQueryOptions(Player subject, ImmutableContextSet contextSet) {
    QueryOptions.Builder queryOptions = this.plugin.getConfiguration().get(ConfigKeys.GLOBAL_QUERY_OPTIONS).toBuilder();
    if (subject.isOp()) {
        queryOptions.option(OP_OPTION, true);
    }

    return queryOptions.context(contextSet).build();
}
 
Example 4
Source File: LuckPermsVaultPermission.java    From LuckPerms with MIT License 4 votes vote down vote up
QueryOptions getQueryOptions(@Nullable UUID uuid, @Nullable String world) {
    MutableContextSet context;

    Player player = Optional.ofNullable(uuid).flatMap(u -> this.plugin.getBootstrap().getPlayer(u)).orElse(null);
    if (player != null) {
        context = this.plugin.getContextManager().getContext(player).mutableCopy();
    } else {
        context = this.plugin.getContextManager().getStaticContext().mutableCopy();
    }

    String playerWorld = player == null ? null : player.getWorld().getName();

    // if world is null, we want to do a lookup in the players current context
    // if world is not null, we want to do a lookup in that specific world
    if (world != null && !world.isEmpty() && !world.equalsIgnoreCase(playerWorld)) {
        // remove already accumulated worlds
        context.removeAll(DefaultContextKeys.WORLD_KEY);
        // add the vault world
        context.add(DefaultContextKeys.WORLD_KEY, world.toLowerCase());
    }

    // if we're using a special vault server
    if (useVaultServer()) {
        // remove the normal server context from the set
        context.remove(DefaultContextKeys.SERVER_KEY, getServer());

        // add the vault specific server
        if (!getVaultServer().equals("global")) {
            context.add(DefaultContextKeys.SERVER_KEY, getVaultServer());
        }
    }

    boolean op = false;
    if (player != null) {
        op = player.isOp();
    } else if (uuid != null && uuid.version() == 2) { // npc
        op = this.plugin.getConfiguration().get(ConfigKeys.VAULT_NPC_OP_STATUS);
    }

    QueryOptions.Builder builder = QueryOptionsImpl.DEFAULT_CONTEXTUAL.toBuilder();
    builder.context(context);
    builder.flag(Flag.INCLUDE_NODES_WITHOUT_SERVER_CONTEXT, isIncludeGlobal());
    if (op) {
        builder.option(BukkitContextManager.OP_OPTION, true);
    }
    return builder.build();
}