org.spongepowered.api.service.permission.PermissionService Java Examples

The following examples show how to use org.spongepowered.api.service.permission.PermissionService. 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: DescriptionBuilder.java    From LuckPerms with MIT License 6 votes vote down vote up
@Override
public @NonNull PermissionDescription register() throws IllegalStateException {
    if (this.id == null) {
        throw new IllegalStateException("id cannot be null");
    }

    LPPermissionDescription description = this.service.registerPermissionDescription(this.id, this.description, this.container);

    // Set role-templates
    LPSubjectCollection subjects = this.service.getCollection(PermissionService.SUBJECTS_ROLE_TEMPLATE);
    for (Map.Entry<String, Tristate> assignment : this.roles.entrySet()) {
        LPSubject roleSubject = subjects.loadSubject(assignment.getKey()).join();
        roleSubject.getTransientSubjectData().setPermission(ImmutableContextSetImpl.EMPTY, this.id, assignment.getValue());
    }

    // null stuff so this instance can be reused
    this.roles.clear();
    this.id = null;
    this.description = null;

    return description.sponge();
}
 
Example #2
Source File: DescriptionBuilder.java    From LuckPerms with MIT License 6 votes vote down vote up
@Override
public @NonNull PermissionDescription register() throws IllegalStateException {
    if (this.id == null) {
        throw new IllegalStateException("id cannot be null");
    }

    LPPermissionDescription description = this.service.registerPermissionDescription(this.id, this.description, this.container);

    // Set role-templates
    LPSubjectCollection subjects = this.service.getCollection(PermissionService.SUBJECTS_ROLE_TEMPLATE);
    for (Map.Entry<String, Tristate> assignment : this.roles.entrySet()) {
        LPSubject roleSubject = subjects.loadSubject(assignment.getKey()).join();
        roleSubject.getTransientSubjectData().setPermission(ImmutableContextSetImpl.EMPTY, this.id, assignment.getValue());
    }

    // null stuff so this instance can be reused
    this.roles.clear();
    this.id = null;
    this.description = null;

    return description.sponge();
}
 
Example #3
Source File: PermissionHolderSubjectData.java    From LuckPerms with MIT License 6 votes vote down vote up
@Override
public CompletableFuture<Boolean> removeParent(ImmutableContextSet contexts, LPSubjectReference subject) {
    Objects.requireNonNull(contexts, "contexts");
    Objects.requireNonNull(subject, "subject");

    if (!subject.getCollectionIdentifier().equals(PermissionService.SUBJECTS_GROUP)) {
        return CompletableFuture.completedFuture(false);
    }

    Node node = Inheritance.builder(subject.getSubjectIdentifier())
            .withContext(contexts)
            .build();

    if (!this.holder.unsetNode(this.type, node).wasSuccessful()) {
        return CompletableFuture.completedFuture(false);
    }

    return save(this.holder).thenApply(v -> true);
}
 
Example #4
Source File: PermissionHolderSubjectData.java    From LuckPerms with MIT License 6 votes vote down vote up
@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 CompletableFuture.completedFuture(false);
    }

    Node node = Inheritance.builder(subject.getSubjectIdentifier())
            .withContext(contexts)
            .build();

    if (!this.holder.setNode(this.type, node, true).wasSuccessful()) {
        return CompletableFuture.completedFuture(false);
    }

    return save(this.holder).thenApply(v -> true);
}
 
Example #5
Source File: CommandGpVersion.java    From GriefPrevention with MIT License 6 votes vote down vote up
@Override
public CommandResult execute(CommandSource src, CommandContext ctx) {
    if (!src.hasPermission(GPPermissions.COMMAND_VERSION)) {
        return CommandResult.success();
    }

    String version = GriefPreventionPlugin.IMPLEMENTATION_VERSION;
    if (version == null) {
        version = "unknown";
    }
    final String spongePlatform = Sponge.getPlatform().getContainer(Component.IMPLEMENTATION).getName();
    Text gpVersion = Text.of(GriefPreventionPlugin.GP_TEXT, "Running ", TextColors.AQUA, "GriefPrevention ", version);
    Text spongeVersion = Text.of(GriefPreventionPlugin.GP_TEXT, "Running ", TextColors.YELLOW, spongePlatform, " ", GriefPreventionPlugin.SPONGE_VERSION);
    String permissionPlugin = Sponge.getServiceManager().getRegistration(PermissionService.class).get().getPlugin().getId();
    String permissionVersion = Sponge.getServiceManager().getRegistration(PermissionService.class).get().getPlugin().getVersion().orElse("unknown");
    Text permVersion = Text.of(GriefPreventionPlugin.GP_TEXT, "Running ", TextColors.GREEN, permissionPlugin, " ", permissionVersion);
    src.sendMessage(Text.of(gpVersion, "\n", spongeVersion, "\n", permVersion));
    return CommandResult.success();
}
 
Example #6
Source File: UCPerms7.java    From UltimateChat with GNU General Public License v3.0 6 votes vote down vote up
public UCPerms7() {
    this.permissionService = UChat.get().getGame().getServiceManager().getRegistration(PermissionService.class).get().getProvider();
    this.permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "uchat.channel.local.read", Tristate.TRUE);
    this.permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "uchat.channel.local.write", Tristate.TRUE);
    this.permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "uchat.channel.global.read", Tristate.TRUE);
    this.permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "uchat.channel.global.write", Tristate.TRUE);
    this.permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "uchat.cmd.tell", Tristate.TRUE);
    this.permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "uchat.chat.click-urls", Tristate.TRUE);
    this.permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "uchat.cant-ignore.local", Tristate.TRUE);
    this.permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "uchat.chat.hand", Tristate.TRUE);
    this.permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "uchat.cmd.ignore.channel", Tristate.TRUE);
    this.permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "uchat.cmd.ignore.player", Tristate.TRUE);
    this.permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "uchat.cmd.clear", Tristate.TRUE);
    this.permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "uchat.cmd.msgtoggle", Tristate.TRUE);
    this.permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "uchat.password", Tristate.TRUE);
    this.permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "uchat.discord-sync.cmd.base", Tristate.TRUE);
    this.permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "uchat.discord-sync.cmd.generate", Tristate.TRUE);
}
 
Example #7
Source File: UCPerms8.java    From UltimateChat with GNU General Public License v3.0 6 votes vote down vote up
public UCPerms8() {
    this.permissionService = UChat.get().getGame().getServiceManager().getRegistration(PermissionService.class).get().getProvider();
    this.permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "uchat.channel.local.read", Tristate.TRUE);
    this.permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "uchat.channel.local.write", Tristate.TRUE);
    this.permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "uchat.channel.global.read", Tristate.TRUE);
    this.permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "uchat.channel.global.write", Tristate.TRUE);
    this.permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "uchat.cmd.tell", Tristate.TRUE);
    this.permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "uchat.chat.click-urls", Tristate.TRUE);
    this.permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "uchat.cant-ignore.local", Tristate.TRUE);
    this.permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "uchat.chat.hand", Tristate.TRUE);
    this.permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "uchat.cmd.ignore.channel", Tristate.TRUE);
    this.permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "uchat.cmd.ignore.player", Tristate.TRUE);
    this.permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "uchat.cmd.clear", Tristate.TRUE);
    this.permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "uchat.cmd.msgtoggle", Tristate.TRUE);
    this.permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "uchat.password", Tristate.TRUE);
    this.permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "uchat.discord-sync.cmd.base", Tristate.TRUE);
    this.permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "uchat.discord-sync.cmd.generate", Tristate.TRUE);
}
 
Example #8
Source File: UCPerms56.java    From UltimateChat with GNU General Public License v3.0 6 votes vote down vote up
public UCPerms56() {
    this.permissionService = UChat.get().getGame().getServiceManager().getRegistration(PermissionService.class).get().getProvider();
    this.permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "uchat.channel.local.read", Tristate.TRUE);
    this.permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "uchat.channel.local.write", Tristate.TRUE);
    this.permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "uchat.channel.global.read", Tristate.TRUE);
    this.permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "uchat.channel.global.write", Tristate.TRUE);
    this.permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "uchat.cmd.tell", Tristate.TRUE);
    this.permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "uchat.chat.click-urls", Tristate.TRUE);
    this.permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "uchat.cant-ignore.local", Tristate.TRUE);
    this.permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "uchat.chat.hand", Tristate.TRUE);
    this.permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "uchat.cmd.ignore.channel", Tristate.TRUE);
    this.permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "uchat.cmd.ignore.player", Tristate.TRUE);
    this.permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "uchat.cmd.clear", Tristate.TRUE);
    this.permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "uchat.cmd.msgtoggle", Tristate.TRUE);
    this.permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "uchat.password", Tristate.TRUE);
    this.permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "uchat.discord-sync.cmd.base", Tristate.TRUE);
    this.permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "uchat.discord-sync.cmd.generate", Tristate.TRUE);
}
 
Example #9
Source File: ActivePlayerChatView.java    From ChatUI with MIT License 6 votes vote down vote up
private void initNewTab(Player player) {
    this.newTab.addButton("Player List", new NewTab.LaunchTabAction(() -> new Tab(Text.of("Player List"), this.playerList.getRoot())));
    if (ImplementationConfig.isSupported()) {
        if (player.hasPermission(PERM_CONFIG)) {
            ConfigEditTab.Options opts = new ConfigEditTab.Options(
                    player.hasPermission(PERM_CONFIG + ".add"),
                    player.hasPermission(PERM_CONFIG + ".edit"),
                    player.hasPermission(PERM_CONFIG + ".delete"), null);
            this.newTab.addButton("Edit Config", new NewTab.LaunchTabAction(() -> new ConfigEditTab(ImplementationConfig.getRootNode(),
                    ImplementationConfig.getTitle(), opts, ImplementationConfig.getHandler())));
        }
    }
    if (player.hasPermission(PERM_PERMISSIONS)) {
        Optional<PermissionService> optService = Sponge.getServiceManager().provide(PermissionService.class);
        if (optService.isPresent()) {
            this.newTab.addButton("Permissions", new NewTab.LaunchTabAction(() -> new PermissionsTab(optService.get())));
        }
    }
    UUID uuid = player.getUniqueId();
    this.newTab.addButton("Settings", new NewTab.LaunchTabAction(() -> createSettingsTab(uuid)));
}
 
Example #10
Source File: SubjectListPane.java    From ChatUI with MIT License 6 votes vote down vote up
Text renderSubject(Subject subject) {
    HoverAction<?> hover = null;
    if (this.collection.getIdentifier().equals(PermissionService.SUBJECTS_USER)) {
        try {
            UUID uuid = UUID.fromString(subject.getIdentifier());
            Optional<User> user = Sponge.getServiceManager().provideUnchecked(UserStorageService.class).get(uuid);
            if (user.isPresent()) {
                hover = TextActions.showText(Text.of(user.get().getName()));
            }
        } catch (Exception e) {
        }
    }
    return Text.builder(subject.getIdentifier())
            .onHover(hover)
            .onClick(ExtraUtils.clickAction(() -> {
                this.tab.getSubjViewer().setActive(subject, true);
                this.tab.setRoot(this.tab.getSubjViewer());
            }, SubjectListPane.this.tab)).build();
}
 
Example #11
Source File: PermissionsTab.java    From ChatUI with MIT License 5 votes vote down vote up
private static PermissionActions findActions(PermissionService service) {
    ProviderRegistration<PermissionService> reg = Sponge.getServiceManager().getRegistration(PermissionService.class).get();
    if (reg.getPlugin().getId().equals("permissionsex")) {
        // Ensure loaded
        service.loadCollection(PermissionService.SUBJECTS_COMMAND_BLOCK);
        service.loadCollection(PermissionService.SUBJECTS_GROUP);
        service.loadCollection(PermissionService.SUBJECTS_ROLE_TEMPLATE);
        service.loadCollection(PermissionService.SUBJECTS_SYSTEM);
        service.loadCollection(PermissionService.SUBJECTS_USER);
        return new PEXActions();
    }
    return new FallbackPermActions();
}
 
Example #12
Source File: PermissionsTab.java    From ChatUI with MIT License 5 votes vote down vote up
public PermissionsTab(PermissionService service) {
    super(Text.of("Permissions"));
    this.service = service;
    this.actions = findActions(service);
    this.dashboard = createDashboard();
    this.subjListPane = new SubjectListPane(this);
    this.subjViewer = new SubjectViewer(this);
    this.entryDisplayer = new EntryDisplayer(this);
    this.setRoot(this.dashboard);
}
 
Example #13
Source File: GroupSubjectArgument.java    From UltimateCore with MIT License 5 votes vote down vote up
@Nullable
@Override
public Subject parseValue(CommandSource source, CommandArgs args) throws ArgumentParseException {
    String next = args.next();

    PermissionService service = Sponge.getServiceManager().provide(PermissionService.class).get();
    for (Subject subject : Lists.newArrayList(service.getGroupSubjects().getLoadedSubjects())) {
        if (subject.getIdentifier().equalsIgnoreCase(next)) {
            return subject;
        }
    }
    throw args.createError(Messages.getFormatted(source, "core.groupsubjectnotfound", "%level%", next));
}
 
Example #14
Source File: VirtualChestPermissionManager.java    From VirtualChest with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void init()
{
    PermissionService permissionService = Sponge.getServiceManager().provideUnchecked(PermissionService.class);
    if (SpongeUnimplemented.isPermissionServiceProvidedBySponge(permissionService))
    {
        this.logger.warn("VirtualChest could not find the permission service. ");
        this.logger.warn("Features related to permissions may not work normally.");
    }
    else
    {
        permissionService.registerContextCalculator(this);
    }
}
 
Example #15
Source File: CommandGDVersion.java    From GriefDefender with MIT License 5 votes vote down vote up
@CommandAlias("gdversion")
@Description("Displays GriefDefender's version information.")
@Subcommand("version")
public void execute(CommandSource src) {

    final String spongePlatform = Sponge.getPlatform().getContainer(org.spongepowered.api.Platform.Component.IMPLEMENTATION).getName();
    Component gpVersion = TextComponent.builder("")
            .append(GriefDefenderPlugin.GD_TEXT)
            .append("Running ")
            .append("GriefDefender " + GriefDefenderPlugin.IMPLEMENTATION_VERSION, TextColor.AQUA)
            .build();
    Component spongeVersion = TextComponent.builder("")
            .append(GriefDefenderPlugin.GD_TEXT)
            .append("Running ")
            .append(spongePlatform + " " + GriefDefenderPlugin.SPONGE_VERSION, TextColor.YELLOW)
            .build();
    String permissionPlugin = Sponge.getServiceManager().getRegistration(PermissionService.class).get().getPlugin().getId();
    String permissionVersion = Sponge.getServiceManager().getRegistration(PermissionService.class).get().getPlugin().getVersion().orElse("unknown");
    Component permVersion = TextComponent.builder("")
            .append(GriefDefenderPlugin.GD_TEXT)
            .append("Running ")
            .append(permissionPlugin + " " + permissionVersion, TextColor.GREEN)
            .build();
    TextAdapter.sendComponent(src, TextComponent.builder("")
            .append(gpVersion)
            .append("\n")
            .append(spongeVersion)
            .append("\n")
            .append(permVersion)
            .build());
}
 
Example #16
Source File: LPSpongePlugin.java    From LuckPerms with MIT License 5 votes vote down vote up
@Override
protected void setupPlatformHooks() {
    getLogger().info("Registering PermissionService...");
    this.updateEventHandler = UpdateEventHandler.obtain(this);
    this.service = new me.lucko.luckperms.sponge.service.LuckPermsService(this);

    PermissionService oldService = this.bootstrap.getGame().getServiceManager().provide(PermissionService.class).orElse(null);
    if (oldService != null && !(oldService instanceof ProxiedServiceObject)) {

        // before registering our permission service, copy any existing permission descriptions
        Collection<PermissionDescription> permissionDescriptions = oldService.getDescriptions();
        for (PermissionDescription description : permissionDescriptions) {
            if (description instanceof ProxiedServiceObject) {
                continue;
            }
            ProxyFactory.registerDescription(this.service, description);
        }
    }

    if (this.bootstrap.getGame().getPluginManager().getPlugin("permissionsex").isPresent()) {
        getLogger().warn("Detected PermissionsEx - assuming it's loaded for migration.");
        getLogger().warn("Delaying LuckPerms PermissionService registration.");
        this.lateLoad = true;
    } else {
        this.bootstrap.getGame().getServiceManager().setProvider(this.bootstrap, LPPermissionService.class, this.service);
        this.bootstrap.getGame().getServiceManager().setProvider(this.bootstrap, PermissionService.class, this.service.sponge());
    }
}
 
Example #17
Source File: LPSpongePlugin.java    From LuckPerms with MIT License 5 votes vote down vote up
public void lateEnable() {
    if (this.lateLoad) {
        getLogger().info("Providing late registration of PermissionService...");
        this.bootstrap.getGame().getServiceManager().setProvider(this.bootstrap, LPPermissionService.class, this.service);
        this.bootstrap.getGame().getServiceManager().setProvider(this.bootstrap, PermissionService.class, this.service.sponge());
    }
}
 
Example #18
Source File: ProxyFactory.java    From LuckPerms with MIT License 4 votes vote down vote up
public static PermissionService toSponge(LPPermissionService luckPerms) {
    return IS_API_7 ?
            new me.lucko.luckperms.sponge.service.proxy.api7.PermissionServiceProxy(luckPerms) :
            new me.lucko.luckperms.sponge.service.proxy.api6.PermissionServiceProxy(luckPerms);
}
 
Example #19
Source File: VersionHelper8.java    From RedProtect with GNU General Public License v3.0 4 votes vote down vote up
VersionHelper8() {
    PermissionService permissionService = Sponge.getGame().getServiceManager().getRegistration(PermissionService.class).get().getProvider();
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.help", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.border", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.ldeny", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.laccept", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.claim", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.expand-vert", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.delete", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.info", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.addmember", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.addleader", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.addadmin", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.removemember", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.removeadmin", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.removeleader", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.rename", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.welcome", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.blocklimit", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.claimlimit", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.list", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.priority", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.flag", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.near", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.kick", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.teleport", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.settp", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.deltp", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.infowand", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.wand", Tristate.TRUE);

    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.allow-effects", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.allow-fly", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.allow-home", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.allow-potions", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.allow-spawner", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.build", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.button", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.can-grow", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.chest", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.door", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.ender-chest", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.fire", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.fishing", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.flow", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.flow-damage", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.gravity", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.iceform-player", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.iceform-world", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.leaves-decay", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.lever", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.minecart", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.mob-loot", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.passives", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.press-plate", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.pvp", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.smart-door", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.spawn-animals", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.spawn-monsters", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.teleport", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.use-potions", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.redstone", Tristate.TRUE);

    if (RedProtect.get().config.ecoRoot().enchantments.values.size() < Sponge.getRegistry().getAllOf(EnchantmentType.class).size()) {
        Sponge.getRegistry().getAllOf(EnchantmentType.class).forEach((type) -> {
            if (!RedProtect.get().config.ecoRoot().enchantments.values.containsKey(type.getName())) {
                RedProtect.get().config.ecoRoot().enchantments.values.put(type.getName(), 10L);
            }
        });
    }
}
 
Example #20
Source File: VersionHelper7.java    From RedProtect with GNU General Public License v3.0 4 votes vote down vote up
VersionHelper7() {
    PermissionService permissionService = Sponge.getGame().getServiceManager().getRegistration(PermissionService.class).get().getProvider();
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.help", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.border", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.ldeny", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.laccept", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.claim", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.expand-vert", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.delete", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.info", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.addmember", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.addleader", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.addadmin", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.removemember", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.removeadmin", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.removeleader", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.rename", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.welcome", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.blocklimit", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.claimlimit", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.list", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.priority", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.flag", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.near", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.kick", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.teleport", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.settp", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.deltp", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.infowand", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.wand", Tristate.TRUE);

    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.allow-effects", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.allow-fly", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.allow-home", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.allow-potions", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.allow-spawner", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.build", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.button", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.can-grow", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.chest", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.door", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.ender-chest", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.fire", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.fishing", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.flow", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.flow-damage", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.gravity", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.iceform-player", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.iceform-world", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.leaves-decay", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.lever", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.minecart", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.mob-loot", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.passives", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.press-plate", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.pvp", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.smart-door", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.spawn-animals", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.spawn-monsters", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.teleport", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.use-potions", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.redstone", Tristate.TRUE);

    if (RedProtect.get().config.ecoRoot().enchantments.values.size() < Sponge.getRegistry().getAllOf(EnchantmentType.class).size()) {
        Sponge.getRegistry().getAllOf(EnchantmentType.class).forEach((type) -> {
            if (!RedProtect.get().config.ecoRoot().enchantments.values.containsKey(type.getName())) {
                RedProtect.get().config.ecoRoot().enchantments.values.put(type.getName(), 10L);
            }
        });
    }
}
 
Example #21
Source File: VersionHelper56.java    From RedProtect with GNU General Public License v3.0 4 votes vote down vote up
VersionHelper56() {
    PermissionService permissionService = Sponge.getGame().getServiceManager().getRegistration(PermissionService.class).get().getProvider();
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.help", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.border", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.ldeny", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.laccept", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.claim", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.expand-vert", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.delete", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.info", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.addmember", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.addleader", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.addadmin", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.removemember", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.removeadmin", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.removeleader", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.rename", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.welcome", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.blocklimit", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.claimlimit", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.list", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.priority", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.flag", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.near", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.kick", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.teleport", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.settp", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.deltp", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.infowand", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.command.wand", Tristate.TRUE);

    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.allow-effects", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.allow-fly", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.allow-home", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.allow-potions", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.allow-spawner", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.build", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.button", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.can-grow", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.chest", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.door", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.ender-chest", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.fire", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.fishing", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.flow", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.flow-damage", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.gravity", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.iceform-player", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.iceform-world", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.leaves-decay", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.lever", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.minecart", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.mob-loot", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.passives", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.press-plate", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.pvp", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.smart-door", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.spawn-animals", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.spawn-monsters", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.teleport", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.use-potions", Tristate.TRUE);
    permissionService.getDefaults().getTransientSubjectData().setPermission(new HashSet<>(), "redprotect.flag.redstone", Tristate.TRUE);
}
 
Example #22
Source File: GroupSubjectArgument.java    From UltimateCore with MIT License 4 votes vote down vote up
@Override
public List<String> complete(CommandSource src, CommandArgs args, CommandContext context) {
    PermissionService service = Sponge.getServiceManager().provide(PermissionService.class).get();
    return Lists.newArrayList(service.getGroupSubjects().getLoadedSubjects()).stream().map(Contextual::getIdentifier).collect(Collectors.toList());
}
 
Example #23
Source File: GriefPreventionPlugin.java    From GriefPrevention with MIT License 4 votes vote down vote up
@Listener
public void onChangeServiceProvider(ChangeServiceProviderEvent event) {
    if (event.getNewProvider() instanceof PermissionService && this.validateSpongeVersion()) {
        ((PermissionService) event.getNewProvider()).registerContextCalculator(new ClaimContextCalculator());
    }
}
 
Example #24
Source File: Stats.java    From UltimateCore with MIT License 4 votes vote down vote up
public static HashMap<String, Object> collect() {
    final HashMap<String, Object> data = new HashMap<>();
    data.put("serverid", ServerID.getUUID());
    data.put("statsversion", 1);
    data.put("apitype", Sponge.getPlatform().getContainer(Platform.Component.API).getName().toLowerCase());
    data.put("apiversion", Sponge.getPlatform().getContainer(Platform.Component.API).getVersion().orElse("Not Available"));
    data.put("implname", Sponge.getPlatform().getContainer(Platform.Component.IMPLEMENTATION).getName().toLowerCase());
    data.put("implversion", Sponge.getPlatform().getContainer(Platform.Component.IMPLEMENTATION).getVersion().orElse("Not Available"));
    data.put("servertype", Sponge.getPlatform().getType().isServer() ? "server" : "client");
    data.put("mcversion", Sponge.getPlatform().getMinecraftVersion().getName());
    data.put("ucversion", Sponge.getPluginManager().fromInstance(UltimateCore.get()).get().getVersion().orElse("Not Available"));
    data.put("playersonline", Sponge.getServer().getOnlinePlayers().size());
    data.put("worldsloaded", Sponge.getServer().getWorlds().size());
    data.put("osname", System.getProperty("os.name"));
    data.put("osarch", System.getProperty("os.arch").contains("64") ? 64 : 32);
    data.put("osversion", System.getProperty("os.version"));
    data.put("cores", Runtime.getRuntime().availableProcessors());
    data.put("maxram", Runtime.getRuntime().maxMemory());
    data.put("freeram", Runtime.getRuntime().freeMemory());
    data.put("onlinemode", Sponge.getServer().getOnlineMode());
    data.put("javaversion", System.getProperty("java.version"));
    data.put("modules", StringUtil.join(", ", UltimateCore.get().getModuleService().getModules().stream().map(Module::getIdentifier).collect(Collectors.toList())));
    data.put("language", UltimateCore.get().getGeneralConfig().get().getNode("language", "language").getString("EN_US"));
    //Plugins
    StringBuilder pluginbuilder = new StringBuilder();
    for (PluginContainer plugin : Sponge.getPluginManager().getPlugins()) {
        pluginbuilder.append("\n" + plugin.getId() + " / " + plugin.getName() + " / " + plugin.getVersion().orElse("Not Available"));
    }
    data.put("plugins", pluginbuilder.toString());
    //Permissions plugin
    Optional<ProviderRegistration<PermissionService>> permplugin = Sponge.getServiceManager().getRegistration(PermissionService.class);
    if (permplugin.isPresent()) {
        data.put("permissionsplugin", permplugin.get().getPlugin().getId() + " / " + permplugin.get().getPlugin().getName() + " / " + permplugin.get().getPlugin().getVersion().orElse("Not Available"));
    } else {
        data.put("permissionsplugin", "None");
    }
    //Economy plugin
    Optional<ProviderRegistration<EconomyService>> economyplugin = Sponge.getServiceManager().getRegistration(EconomyService.class);
    if (economyplugin.isPresent()) {
        data.put("economyplugin", economyplugin.get().getPlugin().getId() + " / " + economyplugin.get().getPlugin().getName() + " / " + economyplugin.get().getPlugin().getVersion().orElse("Not Available"));
    } else {
        data.put("economyplugin", "None");
    }
    //Return
    return data;
}
 
Example #25
Source File: PermissionServlet.java    From Web-API with MIT License 4 votes vote down vote up
private PermissionService getPermissionService() {
    Optional<PermissionService> optSrv = Sponge.getServiceManager().provide(PermissionService.class);
    if (!optSrv.isPresent())
        throw new NotFoundException("Permission service was not found");
    return optSrv.get();
}
 
Example #26
Source File: PermissionHolderSubject.java    From LuckPerms with MIT License 4 votes vote down vote up
@Override
public boolean isChildOf(ImmutableContextSet contexts, LPSubjectReference parent) {
    return parent.getCollectionIdentifier().equals(PermissionService.SUBJECTS_GROUP) &&
            getPermissionValue(contexts, Inheritance.key(parent.getSubjectIdentifier())).asBoolean();
}
 
Example #27
Source File: LuckPermsService.java    From LuckPerms with MIT License 4 votes vote down vote up
@Override
public PermissionService sponge() {
    return this.spongeProxy;
}
 
Example #28
Source File: GriefDefenderPlugin.java    From GriefDefender with MIT License 4 votes vote down vote up
@Listener
public void onChangeServiceProvider(ChangeServiceProviderEvent event) {
    if (event.getNewProvider() instanceof PermissionService && this.validateSpongeVersion()) {
        ((PermissionService) event.getNewProvider()).registerContextCalculator(new ClaimContextCalculator());
    }
}
 
Example #29
Source File: SpongeUserManager.java    From LuckPerms with MIT License 4 votes vote down vote up
@Override
public String getIdentifier() {
    return PermissionService.SUBJECTS_USER;
}
 
Example #30
Source File: SpongeGroupManager.java    From LuckPerms with MIT License 4 votes vote down vote up
@Override
public String getIdentifier() {
    return PermissionService.SUBJECTS_GROUP;
}