Search in sources :

Example 1 with LPPermissionService

use of me.lucko.luckperms.sponge.service.model.LPPermissionService in project LuckPerms by lucko.

the class ParentAdd method execute.

@Override
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, LPSubjectData subjectData, List<String> args, String label) {
    String collection = args.get(0);
    String name = args.get(1);
    ImmutableContextSet contextSet = ArgumentParser.parseContextSponge(2, args);
    LPPermissionService service = Sponge.getServiceManager().provideUnchecked(LPPermissionService.class);
    if (service.getLoadedCollections().keySet().stream().map(String::toLowerCase).noneMatch(s -> s.equalsIgnoreCase(collection))) {
        MessageUtils.sendPluginMessage(sender, "Warning: SubjectCollection '&4" + collection + "&c' doesn't already exist.");
    }
    LPSubjectCollection c = service.getCollection(collection);
    if (!c.hasRegistered(name).join()) {
        MessageUtils.sendPluginMessage(sender, "Warning: Subject '&4" + name + "&c' doesn't already exist.");
    }
    LPSubject subject = c.loadSubject(name).join();
    if (subjectData.addParent(contextSet, subject.toReference()).join()) {
        MessageUtils.sendPluginMessage(sender, "&aAdded parent &b" + subject.getParentCollection().getIdentifier() + "&a/&b" + subject.getIdentifier() + "&a in context " + SpongeCommandUtils.contextToString(contextSet));
    } else {
        MessageUtils.sendPluginMessage(sender, "Unable to add parent. Does the Subject already have it added?");
    }
    return CommandResult.SUCCESS;
}
Also used : LPPermissionService(me.lucko.luckperms.sponge.service.model.LPPermissionService) LPSubject(me.lucko.luckperms.sponge.service.model.LPSubject) ImmutableContextSet(me.lucko.luckperms.api.context.ImmutableContextSet) LPSubjectCollection(me.lucko.luckperms.sponge.service.model.LPSubjectCollection)

Example 2 with LPPermissionService

use of me.lucko.luckperms.sponge.service.model.LPPermissionService in project LuckPerms by lucko.

the class ParentRemove method execute.

@Override
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, LPSubjectData subjectData, List<String> args, String label) {
    String collection = args.get(0);
    String name = args.get(1);
    ImmutableContextSet contextSet = ArgumentParser.parseContextSponge(2, args);
    LPPermissionService service = Sponge.getServiceManager().provideUnchecked(LPPermissionService.class);
    if (service.getLoadedCollections().keySet().stream().map(String::toLowerCase).noneMatch(s -> s.equalsIgnoreCase(collection))) {
        MessageUtils.sendPluginMessage(sender, "Warning: SubjectCollection '&4" + collection + "&c' doesn't exist.");
    }
    LPSubjectCollection c = service.getCollection(collection);
    if (!c.hasRegistered(name).join()) {
        MessageUtils.sendPluginMessage(sender, "Warning: Subject '&4" + name + "&c' doesn't exist.");
    }
    LPSubject subject = c.loadSubject(name).join();
    if (subjectData.removeParent(contextSet, subject.toReference()).join()) {
        MessageUtils.sendPluginMessage(sender, "&aRemoved parent &b" + subject.getParentCollection().getIdentifier() + "&a/&b" + subject.getIdentifier() + "&a in context " + SpongeCommandUtils.contextToString(contextSet));
    } else {
        MessageUtils.sendPluginMessage(sender, "Unable to remove parent. Are you sure the Subject has it added?");
    }
    return CommandResult.SUCCESS;
}
Also used : LPPermissionService(me.lucko.luckperms.sponge.service.model.LPPermissionService) LPSubject(me.lucko.luckperms.sponge.service.model.LPSubject) ImmutableContextSet(me.lucko.luckperms.api.context.ImmutableContextSet) LPSubjectCollection(me.lucko.luckperms.sponge.service.model.LPSubjectCollection)

Aggregations

ImmutableContextSet (me.lucko.luckperms.api.context.ImmutableContextSet)2 LPPermissionService (me.lucko.luckperms.sponge.service.model.LPPermissionService)2 LPSubject (me.lucko.luckperms.sponge.service.model.LPSubject)2 LPSubjectCollection (me.lucko.luckperms.sponge.service.model.LPSubjectCollection)2