当前位置: 首页>>代码示例>>Java>>正文


Java DataMutateResult类代码示例

本文整理汇总了Java中me.lucko.luckperms.api.DataMutateResult的典型用法代码示例。如果您正苦于以下问题:Java DataMutateResult类的具体用法?Java DataMutateResult怎么用?Java DataMutateResult使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DataMutateResult类属于me.lucko.luckperms.api包,在下文中一共展示了DataMutateResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setPermission

import me.lucko.luckperms.api.DataMutateResult; //导入依赖的package包/类
/**
 * Sets a permission node
 *
 * @param node the node to set
 */
public DataMutateResult setPermission(Node node) {
    if (hasPermission(node, false) != Tristate.UNDEFINED) {
        return DataMutateResult.ALREADY_HAS;
    }

    ImmutableCollection<Node> before = getEnduringNodes().values();

    this.nodesLock.lock();
    try {
        this.nodes.put(node.getFullContexts().makeImmutable(), node);
    } finally {
        this.nodesLock.unlock();
    }
    invalidateCache();

    ImmutableCollection<Node> after = getEnduringNodes().values();

    this.plugin.getEventFactory().handleNodeAdd(node, this, before, after);
    return DataMutateResult.SUCCESS;
}
 
开发者ID:lucko,项目名称:LuckPerms,代码行数:26,代码来源:PermissionHolder.java

示例2: setTransientPermission

import me.lucko.luckperms.api.DataMutateResult; //导入依赖的package包/类
/**
 * Sets a transient permission node
 *
 * @param node the node to set
 */
public DataMutateResult setTransientPermission(Node node) {
    if (hasPermission(node, true) != Tristate.UNDEFINED) {
        return DataMutateResult.ALREADY_HAS;
    }

    ImmutableCollection<Node> before = getTransientNodes().values();

    this.transientNodesLock.lock();
    try {
        this.transientNodes.put(node.getFullContexts().makeImmutable(), node);
    } finally {
        this.transientNodesLock.unlock();
    }

    invalidateCache();

    ImmutableCollection<Node> after = getTransientNodes().values();

    this.plugin.getEventFactory().handleNodeAdd(node, this, before, after);
    return DataMutateResult.SUCCESS;
}
 
开发者ID:lucko,项目名称:LuckPerms,代码行数:27,代码来源:PermissionHolder.java

示例3: unsetPermission

import me.lucko.luckperms.api.DataMutateResult; //导入依赖的package包/类
/**
 * Unsets a permission node
 *
 * @param node the node to unset
 */
public DataMutateResult unsetPermission(Node node) {
    if (hasPermission(node, false) == Tristate.UNDEFINED) {
        return DataMutateResult.LACKS;
    }

    ImmutableCollection<Node> before = getEnduringNodes().values();

    this.nodesLock.lock();
    try {
        this.nodes.get(node.getFullContexts().makeImmutable()).removeIf(e -> e.almostEquals(node));
    } finally {
        this.nodesLock.unlock();
    }

    invalidateCache();

    ImmutableCollection<Node> after = getEnduringNodes().values();
    this.plugin.getEventFactory().handleNodeRemove(node, this, before, after);
    return DataMutateResult.SUCCESS;
}
 
开发者ID:lucko,项目名称:LuckPerms,代码行数:26,代码来源:PermissionHolder.java

示例4: unsetTransientPermission

import me.lucko.luckperms.api.DataMutateResult; //导入依赖的package包/类
/**
 * Unsets a transient permission node
 *
 * @param node the node to unset
 */
public DataMutateResult unsetTransientPermission(Node node) {
    if (hasPermission(node, true) == Tristate.UNDEFINED) {
        return DataMutateResult.LACKS;
    }

    ImmutableCollection<Node> before = getTransientNodes().values();

    this.transientNodesLock.lock();
    try {
        this.transientNodes.get(node.getFullContexts().makeImmutable()).removeIf(e -> e.almostEquals(node));
    } finally {
        this.transientNodesLock.unlock();
    }

    invalidateCache();

    ImmutableCollection<Node> after = getTransientNodes().values();
    this.plugin.getEventFactory().handleNodeRemove(node, this, before, after);
    return DataMutateResult.SUCCESS;
}
 
开发者ID:lucko,项目名称:LuckPerms,代码行数:26,代码来源:PermissionHolder.java

示例5: addToGroup

import me.lucko.luckperms.api.DataMutateResult; //导入依赖的package包/类
@Override
public boolean addToGroup(OfflinePlayer player, String group) {
    Group newGroup = luckPermsApi.getGroup(group);
    if (newGroup == null) {
        return false;
    }

    User user = luckPermsApi.getUser(player.getName());
    if (user == null) {
        return false;
    }

    DataMutateResult result = user.setPermissionUnchecked(luckPermsApi.getNodeFactory().makeGroupNode(newGroup).build());
    if (result == DataMutateResult.FAIL) {
        return false;
    }

    saveUser(user);
    luckPermsApi.cleanupUser(user);

    return true;
}
 
开发者ID:AuthMe,项目名称:AuthMeReloaded,代码行数:23,代码来源:LuckPermsHandler.java

示例6: removeFromGroup

import me.lucko.luckperms.api.DataMutateResult; //导入依赖的package包/类
@Override
public boolean removeFromGroup(OfflinePlayer player, String group) {
    User user = luckPermsApi.getUser(player.getName());
    if (user == null) {
        return false;
    }

    Group permissionGroup = luckPermsApi.getGroup(group);
    if (permissionGroup == null) {
        return false;
    }

    Node groupNode = luckPermsApi.getNodeFactory().makeGroupNode(permissionGroup).build();
    boolean result = user.unsetPermissionUnchecked(groupNode) != DataMutateResult.FAIL;

    luckPermsApi.cleanupUser(user);
    return result;
}
 
开发者ID:AuthMe,项目名称:AuthMeReloaded,代码行数:19,代码来源:LuckPermsHandler.java

示例7: setGroup

import me.lucko.luckperms.api.DataMutateResult; //导入依赖的package包/类
@Override
public boolean setGroup(OfflinePlayer player, String group) {
    User user = luckPermsApi.getUser(player.getName());
    if (user == null) {
        return false;
    }
    Group permissionGroup = luckPermsApi.getGroup(group);
    if (permissionGroup == null) {
        return false;
    }
    Node groupNode = luckPermsApi.getNodeFactory().makeGroupNode(permissionGroup).build();
    DataMutateResult result = user.setPermissionUnchecked(groupNode);
    if (result == DataMutateResult.FAIL) {
        return false;
    }
    user.clearMatching(node -> node.isGroupNode() && !node.getGroupName().equals(permissionGroup.getName()));

    saveUser(user);
    luckPermsApi.cleanupUser(user);
    return true;
}
 
开发者ID:AuthMe,项目名称:AuthMeReloaded,代码行数:22,代码来源:LuckPermsHandler.java

示例8: addParent

import me.lucko.luckperms.api.DataMutateResult; //导入依赖的package包/类
@Override
public CompletableFuture<Boolean> addParent(ImmutableContextSet contexts, LPSubjectReference subject) {
    Objects.requireNonNull(contexts, "contexts");
    Objects.requireNonNull(subject, "subject");

    if (subject.getCollectionIdentifier().equals(PermissionService.SUBJECTS_GROUP)) {
        return subject.resolveLp().thenCompose(sub -> {
            DataMutateResult result;

            if (this.enduring) {
                result = this.holder.setPermission(NodeFactory.buildGroupNode(sub.getIdentifier())
                        .withExtraContext(contexts)
                        .build());
            } else {
                result = this.holder.setTransientPermission(NodeFactory.buildGroupNode(sub.getIdentifier())
                        .withExtraContext(contexts)
                        .build());
            }

            if (!result.asBoolean()) {
                return CompletableFuture.completedFuture(false);
            }

            return objectSave(this.holder).thenApply(v -> true);
        });
    }
    return CompletableFuture.completedFuture(false);
}
 
开发者ID:lucko,项目名称:LuckPerms,代码行数:29,代码来源:LuckPermsSubjectData.java

示例9: removeParent

import me.lucko.luckperms.api.DataMutateResult; //导入依赖的package包/类
@Override
public CompletableFuture<Boolean> removeParent(ImmutableContextSet contexts, LPSubjectReference subject) {
    Objects.requireNonNull(contexts, "contexts");
    Objects.requireNonNull(subject, "subject");

    if (subject.getCollectionIdentifier().equals(PermissionService.SUBJECTS_GROUP)) {
        subject.resolveLp().thenCompose(sub -> {
            DataMutateResult result;

            if (this.enduring) {
                result = this.holder.unsetPermission(NodeFactory.buildGroupNode(sub.getIdentifier())
                        .withExtraContext(contexts)
                        .build());
            } else {
                result = this.holder.unsetTransientPermission(NodeFactory.buildGroupNode(sub.getIdentifier())
                        .withExtraContext(contexts)
                        .build());
            }

            if (!result.asBoolean()) {
                return CompletableFuture.completedFuture(false);
            }

            return objectSave(this.holder).thenApply(v -> true);
        });
    }
    return CompletableFuture.completedFuture(false);
}
 
开发者ID:lucko,项目名称:LuckPerms,代码行数:29,代码来源:LuckPermsSubjectData.java

示例10: execute

import me.lucko.luckperms.api.DataMutateResult; //导入依赖的package包/类
@Override
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args, String label, CommandPermission permission) throws CommandException {
    if (ArgumentPermissions.checkModifyPerms(plugin, sender, permission, holder)) {
        Message.COMMAND_NO_PERMISSION.send(sender);
        return CommandResult.NO_PERMISSION;
    }

    String node = ArgumentUtils.handleString(0, args);
    MutableContextSet context = ArgumentUtils.handleContext(1, args, plugin);

    if (ArgumentPermissions.checkContext(plugin, sender, permission, context)) {
        Message.COMMAND_NO_PERMISSION.send(sender);
        return CommandResult.NO_PERMISSION;
    }

    if (ArgumentPermissions.checkArguments(plugin, sender, permission, node)) {
        Message.COMMAND_NO_PERMISSION.send(sender);
        return CommandResult.NO_PERMISSION;
    }

    DataMutateResult result = holder.unsetPermission(NodeFactory.builder(node).withExtraContext(context).build());

    if (result.asBoolean()) {
        Message.UNSETPERMISSION_SUCCESS.send(sender, node, holder.getFriendlyName(), CommandUtils.contextSetToString(context));

        ExtendedLogEntry.build().actor(sender).acted(holder)
                .action("permission", "unset", node, context)
                .build().submit(plugin, sender);

        save(holder, sender, plugin);
        return CommandResult.SUCCESS;
    } else {
        Message.DOES_NOT_HAVE_PERMISSION.send(sender, holder.getFriendlyName(), node, CommandUtils.contextSetToString(context));
        return CommandResult.STATE_ERROR;
    }
}
 
开发者ID:lucko,项目名称:LuckPerms,代码行数:37,代码来源:PermissionUnset.java

示例11: execute

import me.lucko.luckperms.api.DataMutateResult; //导入依赖的package包/类
@Override
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args, String label, CommandPermission permission) throws CommandException {
    if (ArgumentPermissions.checkModifyPerms(plugin, sender, permission, holder)) {
        Message.COMMAND_NO_PERMISSION.send(sender);
        return CommandResult.NO_PERMISSION;
    }

    String node = ArgumentUtils.handleString(0, args);
    boolean value = ArgumentUtils.handleBoolean(1, args);
    long duration = ArgumentUtils.handleDuration(2, args);
    MutableContextSet context = ArgumentUtils.handleContext(3, args, plugin);

    if (ArgumentPermissions.checkContext(plugin, sender, permission, context)) {
        Message.COMMAND_NO_PERMISSION.send(sender);
        return CommandResult.NO_PERMISSION;
    }

    if (ArgumentPermissions.checkArguments(plugin, sender, permission, node)) {
        Message.COMMAND_NO_PERMISSION.send(sender);
        return CommandResult.NO_PERMISSION;
    }

    TemporaryModifier modifier = plugin.getConfiguration().get(ConfigKeys.TEMPORARY_ADD_BEHAVIOUR);
    Map.Entry<DataMutateResult, Node> result = holder.setPermission(NodeFactory.builder(node).setValue(value).withExtraContext(context).setExpiry(duration).build(), modifier);

    if (result.getKey().asBoolean()) {
        duration = result.getValue().getExpiryUnixTime();
        Message.SETPERMISSION_TEMP_SUCCESS.send(sender, node, value, holder.getFriendlyName(), DateUtil.formatDateDiff(duration), CommandUtils.contextSetToString(context));

        ExtendedLogEntry.build().actor(sender).acted(holder)
                .action("permission", "settemp", node, value, duration, context)
                .build().submit(plugin, sender);

        save(holder, sender, plugin);
        return CommandResult.SUCCESS;
    } else {
        Message.ALREADY_HAS_TEMP_PERMISSION.send(sender, holder.getFriendlyName(), node, CommandUtils.contextSetToString(context));
        return CommandResult.STATE_ERROR;
    }
}
 
开发者ID:lucko,项目名称:LuckPerms,代码行数:41,代码来源:PermissionSetTemp.java

示例12: execute

import me.lucko.luckperms.api.DataMutateResult; //导入依赖的package包/类
@Override
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args, String label, CommandPermission permission) throws CommandException {
    if (ArgumentPermissions.checkModifyPerms(plugin, sender, permission, holder)) {
        Message.COMMAND_NO_PERMISSION.send(sender);
        return CommandResult.NO_PERMISSION;
    }

    String node = ArgumentUtils.handleString(0, args);
    boolean value = ArgumentUtils.handleBoolean(1, args);
    MutableContextSet context = ArgumentUtils.handleContext(2, args, plugin);

    if (ArgumentPermissions.checkContext(plugin, sender, permission, context)) {
        Message.COMMAND_NO_PERMISSION.send(sender);
        return CommandResult.NO_PERMISSION;
    }

    if (ArgumentPermissions.checkArguments(plugin, sender, permission, node)) {
        Message.COMMAND_NO_PERMISSION.send(sender);
        return CommandResult.NO_PERMISSION;
    }

    DataMutateResult result = holder.setPermission(NodeFactory.builder(node).setValue(value).withExtraContext(context).build());

    if (result.asBoolean()) {
        Message.SETPERMISSION_SUCCESS.send(sender, node, value, holder.getFriendlyName(), CommandUtils.contextSetToString(context));

        ExtendedLogEntry.build().actor(sender).acted(holder)
                .action("permission", "set", node, value, context)
                .build().submit(plugin, sender);

        save(holder, sender, plugin);
        return CommandResult.SUCCESS;
    } else {
        Message.ALREADY_HASPERMISSION.send(sender, holder.getFriendlyName(), node, CommandUtils.contextSetToString(context));
        return CommandResult.STATE_ERROR;
    }
}
 
开发者ID:lucko,项目名称:LuckPerms,代码行数:38,代码来源:PermissionSet.java

示例13: execute

import me.lucko.luckperms.api.DataMutateResult; //导入依赖的package包/类
@Override
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args, String label, CommandPermission permission) throws CommandException {
    if (ArgumentPermissions.checkModifyPerms(plugin, sender, permission, holder)) {
        Message.COMMAND_NO_PERMISSION.send(sender);
        return CommandResult.NO_PERMISSION;
    }

    String node = ArgumentUtils.handleString(0, args);
    MutableContextSet context = ArgumentUtils.handleContext(1, args, plugin);

    if (ArgumentPermissions.checkContext(plugin, sender, permission, context)) {
        Message.COMMAND_NO_PERMISSION.send(sender);
        return CommandResult.NO_PERMISSION;
    }

    if (ArgumentPermissions.checkArguments(plugin, sender, permission, node)) {
        Message.COMMAND_NO_PERMISSION.send(sender);
        return CommandResult.NO_PERMISSION;
    }

    DataMutateResult result = holder.unsetPermission(NodeFactory.builder(node).setExpiry(10L).withExtraContext(context).build());

    if (result.asBoolean()) {
        Message.UNSET_TEMP_PERMISSION_SUCCESS.send(sender, node, holder.getFriendlyName(), CommandUtils.contextSetToString(context));

        ExtendedLogEntry.build().actor(sender).acted(holder)
                .action("permission", "unsettemp", node, context)
                .build().submit(plugin, sender);

        save(holder, sender, plugin);
        return CommandResult.SUCCESS;
    } else {
        Message.DOES_NOT_HAVE_TEMP_PERMISSION.send(sender, holder.getFriendlyName(), node, CommandUtils.contextSetToString(context));
        return CommandResult.STATE_ERROR;
    }
}
 
开发者ID:lucko,项目名称:LuckPerms,代码行数:37,代码来源:PermissionUnsetTemp.java

示例14: execute

import me.lucko.luckperms.api.DataMutateResult; //导入依赖的package包/类
@Override
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args, String label, CommandPermission permission) throws CommandException {
    if (ArgumentPermissions.checkModifyPerms(plugin, sender, permission, holder)) {
        Message.COMMAND_NO_PERMISSION.send(sender);
        return CommandResult.NO_PERMISSION;
    }

    int priority = ArgumentUtils.handlePriority(0, args);
    String meta = ArgumentUtils.handleString(1, args);
    MutableContextSet context = ArgumentUtils.handleContext(2, args, plugin);

    if (ArgumentPermissions.checkContext(plugin, sender, permission, context)) {
        Message.COMMAND_NO_PERMISSION.send(sender);
        return CommandResult.NO_PERMISSION;
    }

    DataMutateResult result = holder.setPermission(NodeFactory.buildChatMetaNode(this.type, priority, meta).withExtraContext(context).build());
    if (result.asBoolean()) {
        TextComponent.Builder builder = TextUtils.fromLegacy(Message.ADD_CHATMETA_SUCCESS.asString(plugin.getLocaleManager(), holder.getFriendlyName(), this.type.name().toLowerCase(), meta, priority, CommandUtils.contextSetToString(context)), CommandManager.SECTION_CHAR).toBuilder();
        HoverEvent event = new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextUtils.fromLegacy(
                "¥3Raw " + this.type.name().toLowerCase() + ": ¥r" + meta,
                '¥'
        ));
        builder.applyDeep(c -> c.hoverEvent(event));
        sender.sendMessage(builder.build());

        ExtendedLogEntry.build().actor(sender).acted(holder)
                .action("meta" , "add" + this.type.name().toLowerCase(), priority, meta, context)
                .build().submit(plugin, sender);

        save(holder, sender, plugin);
        return CommandResult.SUCCESS;
    } else {
        Message.ALREADY_HAS_CHAT_META.send(sender, holder.getFriendlyName(), this.type.name().toLowerCase(), meta, priority, CommandUtils.contextSetToString(context));
        return CommandResult.STATE_ERROR;
    }
}
 
开发者ID:lucko,项目名称:LuckPerms,代码行数:38,代码来源:MetaAddChatMeta.java

示例15: execute

import me.lucko.luckperms.api.DataMutateResult; //导入依赖的package包/类
@Override
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args, String label, CommandPermission permission) throws CommandException {
    if (ArgumentPermissions.checkModifyPerms(plugin, sender, permission, holder)) {
        Message.COMMAND_NO_PERMISSION.send(sender);
        return CommandResult.NO_PERMISSION;
    }

    String groupName = ArgumentUtils.handleNameWithSpace(0, args);
    MutableContextSet context = ArgumentUtils.handleContext(1, args, plugin);

    if (ArgumentPermissions.checkContext(plugin, sender, permission, context)) {
        Message.COMMAND_NO_PERMISSION.send(sender);
        return CommandResult.NO_PERMISSION;
    }

    if (ArgumentPermissions.checkArguments(plugin, sender, permission, groupName)) {
        Message.COMMAND_NO_PERMISSION.send(sender);
        return CommandResult.NO_PERMISSION;
    }

    DataMutateResult result = holder.unsetPermission(NodeFactory.buildGroupNode(groupName).setExpiry(10L).withExtraContext(context).build());

    if (result.asBoolean()) {
        Message.UNSET_TEMP_INHERIT_SUCCESS.send(sender, holder.getFriendlyName(), groupName, CommandUtils.contextSetToString(context));

        ExtendedLogEntry.build().actor(sender).acted(holder)
                .action("parent", "removetemp", groupName, context)
                .build().submit(plugin, sender);

        save(holder, sender, plugin);
        return CommandResult.SUCCESS;
    } else {
        Message.DOES_NOT_TEMP_INHERIT.send(sender, holder.getFriendlyName(), groupName, CommandUtils.contextSetToString(context));
        return CommandResult.STATE_ERROR;
    }
}
 
开发者ID:lucko,项目名称:LuckPerms,代码行数:37,代码来源:ParentRemoveTemp.java


注:本文中的me.lucko.luckperms.api.DataMutateResult类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。