Search in sources :

Example 1 with PermissionInformation

use of io.github.nucleuspowered.nucleus.internal.permissions.PermissionInformation in project Nucleus by NucleusPowered.

the class KittyCannonCommand method permissionSuffixesToRegister.

@Override
protected Map<String, PermissionInformation> permissionSuffixesToRegister() {
    return new HashMap<String, PermissionInformation>() {

        {
            MessageProvider provider = plugin.getMessageProvider();
            put("damage", new PermissionInformation(provider.getMessageWithFormat("permission.kittycannon.damage"), SuggestedLevel.ADMIN));
            put("break", new PermissionInformation(provider.getMessageWithFormat("permission.kittycannon.break"), SuggestedLevel.ADMIN));
            put("fire", new PermissionInformation(provider.getMessageWithFormat("permission.kittycannon.fire"), SuggestedLevel.ADMIN));
        }
    };
}
Also used : MessageProvider(io.github.nucleuspowered.nucleus.internal.messages.MessageProvider) HashMap(java.util.HashMap) PermissionInformation(io.github.nucleuspowered.nucleus.internal.permissions.PermissionInformation)

Example 2 with PermissionInformation

use of io.github.nucleuspowered.nucleus.internal.permissions.PermissionInformation in project Nucleus by NucleusPowered.

the class FlyCommand method permissionSuffixesToRegister.

@Override
public Map<String, PermissionInformation> permissionSuffixesToRegister() {
    Map<String, PermissionInformation> m = new HashMap<>();
    m.put("others", new PermissionInformation(plugin.getMessageProvider().getMessageWithFormat("permission.others", this.getAliases()[0]), SuggestedLevel.ADMIN));
    return m;
}
Also used : HashMap(java.util.HashMap) PermissionInformation(io.github.nucleuspowered.nucleus.internal.permissions.PermissionInformation)

Example 3 with PermissionInformation

use of io.github.nucleuspowered.nucleus.internal.permissions.PermissionInformation in project Nucleus by NucleusPowered.

the class GetPosCommand method permissionSuffixesToRegister.

@Override
protected Map<String, PermissionInformation> permissionSuffixesToRegister() {
    Map<String, PermissionInformation> mspi = super.permissionSuffixesToRegister();
    mspi.put("others", new PermissionInformation(plugin.getMessageProvider().getMessageWithFormat("permission.getpos.others"), SuggestedLevel.MOD));
    return mspi;
}
Also used : PermissionInformation(io.github.nucleuspowered.nucleus.internal.permissions.PermissionInformation)

Example 4 with PermissionInformation

use of io.github.nucleuspowered.nucleus.internal.permissions.PermissionInformation in project Nucleus by NucleusPowered.

the class NucleusPlugin method registerPermissions.

@Override
protected void registerPermissions() {
    Optional<PermissionService> ops = Sponge.getServiceManager().provide(PermissionService.class);
    ops.ifPresent(permissionService -> {
        Map<String, PermissionInformation> m = this.getPermissionRegistry().getPermissions();
        m.entrySet().stream().filter(x -> {
            SuggestedLevel lvl = x.getValue().level;
            return lvl == SuggestedLevel.ADMIN || lvl == SuggestedLevel.OWNER;
        }).filter(x -> x.getValue().isNormal).forEach(k -> permissionService.newDescriptionBuilder(this).assign(PermissionDescription.ROLE_ADMIN, true).description(k.getValue().description).id(k.getKey()).register());
        m.entrySet().stream().filter(x -> x.getValue().level == SuggestedLevel.MOD).filter(x -> x.getValue().isNormal).forEach(k -> permissionService.newDescriptionBuilder(this).assign(PermissionDescription.ROLE_STAFF, true).description(k.getValue().description).id(k.getKey()).register());
        m.entrySet().stream().filter(x -> x.getValue().level == SuggestedLevel.USER).filter(x -> x.getValue().isNormal).forEach(k -> permissionService.newDescriptionBuilder(this).assign(PermissionDescription.ROLE_USER, true).description(k.getValue().description).id(k.getKey()).register());
    });
}
Also used : PermissionService(org.spongepowered.api.service.permission.PermissionService) GameStoppedServerEvent(org.spongepowered.api.event.game.state.GameStoppedServerEvent) CatalogTypeFinalStaticProcessor(io.github.nucleuspowered.nucleus.internal.CatalogTypeFinalStaticProcessor) TypeToken(com.google.gson.reflect.TypeToken) GameInitializationEvent(org.spongepowered.api.event.game.state.GameInitializationEvent) VERSION(io.github.nucleuspowered.nucleus.PluginInfo.VERSION) PermissionService(org.spongepowered.api.service.permission.PermissionService) Map(java.util.Map) SuggestedLevel(io.github.nucleuspowered.nucleus.internal.permissions.SuggestedLevel) ServiceChangeListener(io.github.nucleuspowered.nucleus.internal.permissions.ServiceChangeListener) Path(java.nio.file.Path) PrintWriter(java.io.PrintWriter) CommandPermissionHandler(io.github.nucleuspowered.nucleus.internal.CommandPermissionHandler) NameBanService(io.github.nucleuspowered.nucleus.dataservices.NameBanService) Set(java.util.Set) ResourceMessageProvider(io.github.nucleuspowered.nucleus.internal.messages.ResourceMessageProvider) MessageProvider(io.github.nucleuspowered.nucleus.internal.messages.MessageProvider) BaseModuleEvent(io.github.nucleuspowered.nucleus.internal.qsml.event.BaseModuleEvent) ConfigException(com.typesafe.config.ConfigException) KitService(io.github.nucleuspowered.nucleus.dataservices.KitService) ConfigurateHelper(io.github.nucleuspowered.nucleus.configurate.ConfigurateHelper) ModularGeneralService(io.github.nucleuspowered.nucleus.dataservices.modular.ModularGeneralService) PermissionInformation(io.github.nucleuspowered.nucleus.internal.permissions.PermissionInformation) GamePostInitializationEvent(org.spongepowered.api.event.game.state.GamePostInitializationEvent) TextParsingUtils(io.github.nucleuspowered.nucleus.internal.text.TextParsingUtils) Supplier(java.util.function.Supplier) ID(io.github.nucleuspowered.nucleus.PluginInfo.ID) Lists(com.google.common.collect.Lists) Text(org.spongepowered.api.text.Text) WorldDataManager(io.github.nucleuspowered.nucleus.dataservices.loaders.WorldDataManager) NucleusLoggerProxy(io.github.nucleuspowered.nucleus.internal.qsml.NucleusLoggerProxy) QuickStartModuleConstructor(io.github.nucleuspowered.nucleus.internal.qsml.QuickStartModuleConstructor) NucleusTeleportHandler(io.github.nucleuspowered.nucleus.internal.teleport.NucleusTeleportHandler) NucleusModuleService(io.github.nucleuspowered.nucleus.api.service.NucleusModuleService) QuickStartModuleLoaderException(uk.co.drnaylor.quickstart.exceptions.QuickStartModuleLoaderException) ModuleData(uk.co.drnaylor.quickstart.annotations.ModuleData) PluginContainer(org.spongepowered.api.plugin.PluginContainer) TextColors(org.spongepowered.api.text.format.TextColors) Nullable(javax.annotation.Nullable) WarmupConfig(io.github.nucleuspowered.nucleus.modules.core.config.WarmupConfig) NucleusAPITokens(io.github.nucleuspowered.nucleus.api.NucleusAPITokens) UserCacheService(io.github.nucleuspowered.nucleus.dataservices.UserCacheService) UserDataManager(io.github.nucleuspowered.nucleus.dataservices.loaders.UserDataManager) Files(java.nio.file.Files) CommandsConfig(io.github.nucleuspowered.nucleus.config.CommandsConfig) StringWriter(java.io.StringWriter) TextFileController(io.github.nucleuspowered.nucleus.internal.TextFileController) IOException(java.io.IOException) Reloadable(io.github.nucleuspowered.nucleus.internal.interfaces.Reloadable) QuickStartModuleDiscoveryException(uk.co.drnaylor.quickstart.exceptions.QuickStartModuleDiscoveryException) PreloadTasks(io.github.nucleuspowered.nucleus.internal.PreloadTasks) NucleusTokenServiceImpl(io.github.nucleuspowered.nucleus.internal.text.NucleusTokenServiceImpl) ObjectMappingException(ninja.leaping.configurate.objectmapping.ObjectMappingException) Paths(java.nio.file.Paths) MessageReceiver(org.spongepowered.api.text.channel.MessageReceiver) ConsoleSource(org.spongepowered.api.command.source.ConsoleSource) Game(org.spongepowered.api.Game) NoModuleException(uk.co.drnaylor.quickstart.exceptions.NoModuleException) EconHelper(io.github.nucleuspowered.nucleus.internal.EconHelper) Strategy(uk.co.drnaylor.quickstart.modulecontainers.discoverystrategies.Strategy) DESCRIPTION(io.github.nucleuspowered.nucleus.PluginInfo.DESCRIPTION) CoreModule(io.github.nucleuspowered.nucleus.modules.core.CoreModule) CoreConfigAdapter(io.github.nucleuspowered.nucleus.modules.core.config.CoreConfigAdapter) NucleusWarmupManagerService(io.github.nucleuspowered.nucleus.api.service.NucleusWarmupManagerService) ItemDataService(io.github.nucleuspowered.nucleus.dataservices.ItemDataService) Order(org.spongepowered.api.event.Order) Gson(com.google.gson.Gson) CoreConfig(io.github.nucleuspowered.nucleus.modules.core.config.CoreConfig) NucleusMessageTokenService(io.github.nucleuspowered.nucleus.api.service.NucleusMessageTokenService) WorldCorrector(io.github.nucleuspowered.nucleus.internal.WorldCorrector) EconomyService(org.spongepowered.api.service.economy.EconomyService) ClientMessageReciever(io.github.nucleuspowered.nucleus.internal.client.ClientMessageReciever) GamePreInitializationEvent(org.spongepowered.api.event.game.state.GamePreInitializationEvent) UniqueUserCountTransientModule(io.github.nucleuspowered.nucleus.modules.core.datamodules.UniqueUserCountTransientModule) Sponge(org.spongepowered.api.Sponge) Instant(java.time.Instant) Sets(com.google.common.collect.Sets) DataProviders(io.github.nucleuspowered.nucleus.dataservices.dataproviders.DataProviders) List(java.util.List) NAME(io.github.nucleuspowered.nucleus.PluginInfo.NAME) GameStartedServerEvent(org.spongepowered.api.event.game.state.GameStartedServerEvent) Optional(java.util.Optional) ConfigMessageProvider(io.github.nucleuspowered.nucleus.internal.messages.ConfigMessageProvider) Asset(org.spongepowered.api.asset.Asset) DocGenCache(io.github.nucleuspowered.nucleus.internal.docgen.DocGenCache) PermissionDescription(org.spongepowered.api.service.permission.PermissionDescription) GameStartingServerEvent(org.spongepowered.api.event.game.state.GameStartingServerEvent) Platform(org.spongepowered.api.Platform) Inject(javax.inject.Inject) PermissionRegistry(io.github.nucleuspowered.nucleus.internal.PermissionRegistry) ModuleRegistrationProxyService(io.github.nucleuspowered.nucleus.internal.qsml.ModuleRegistrationProxyService) NucleusConfigAdapter(io.github.nucleuspowered.nucleus.internal.qsml.NucleusConfigAdapter) Task(org.spongepowered.api.scheduler.Task) GameState(org.spongepowered.api.GameState) IncorrectAdapterTypeException(uk.co.drnaylor.quickstart.exceptions.IncorrectAdapterTypeException) WarmupManager(io.github.nucleuspowered.nucleus.internal.services.WarmupManager) Logger(org.slf4j.Logger) HoconConfigurationLoader(ninja.leaping.configurate.hocon.HoconConfigurationLoader) InternalServiceManager(io.github.nucleuspowered.nucleus.internal.InternalServiceManager) ConstructionPhase(uk.co.drnaylor.quickstart.enums.ConstructionPhase) ConfigDir(org.spongepowered.api.config.ConfigDir) Maps(com.google.common.collect.Maps) Plugin(org.spongepowered.api.plugin.Plugin) UUIDChangeService(io.github.nucleuspowered.nucleus.modules.core.service.UUIDChangeService) Listener(org.spongepowered.api.event.Listener) DiscoveryModuleContainer(uk.co.drnaylor.quickstart.modulecontainers.DiscoveryModuleContainer) DebugLogger(io.github.nucleuspowered.nucleus.logging.DebugLogger) Collections(java.util.Collections) SuggestedLevel(io.github.nucleuspowered.nucleus.internal.permissions.SuggestedLevel) PermissionInformation(io.github.nucleuspowered.nucleus.internal.permissions.PermissionInformation)

Example 5 with PermissionInformation

use of io.github.nucleuspowered.nucleus.internal.permissions.PermissionInformation in project Nucleus by NucleusPowered.

the class PrintPermsCommand method executeCommand.

@Override
public CommandResult executeCommand(CommandSource src, CommandContext args) throws Exception {
    Map<String, PermissionInformation> l = plugin.getPermissionRegistry().getPermissions();
    List<String> notsuggested = l.entrySet().stream().filter(x -> x.getValue().level == SuggestedLevel.NONE).map(Map.Entry::getKey).collect(Collectors.toList());
    List<String> owner = l.entrySet().stream().filter(x -> x.getValue().level == SuggestedLevel.NONE).map(Map.Entry::getKey).collect(Collectors.toList());
    List<String> admin = l.entrySet().stream().filter(x -> x.getValue().level == SuggestedLevel.ADMIN).map(Map.Entry::getKey).collect(Collectors.toList());
    List<String> mod = l.entrySet().stream().filter(x -> x.getValue().level == SuggestedLevel.MOD).map(Map.Entry::getKey).collect(Collectors.toList());
    List<String> user = l.entrySet().stream().filter(x -> x.getValue().level == SuggestedLevel.USER).map(Map.Entry::getKey).collect(Collectors.toList());
    String file = "plugin-perms.txt";
    BufferedWriter f = new BufferedWriter(new FileWriter(file));
    Consumer<String> permWriter = x -> {
        try {
            f.write(x);
            f.newLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
    };
    f.write("Not Suggested");
    f.write("-----");
    f.newLine();
    notsuggested.stream().sorted().forEach(permWriter);
    f.newLine();
    f.write("Owner");
    f.write("-----");
    f.newLine();
    owner.stream().sorted().forEach(permWriter);
    f.newLine();
    f.write("Admin");
    f.write("-----");
    f.newLine();
    admin.stream().sorted().forEach(permWriter);
    f.newLine();
    f.write("Mod");
    f.write("-----");
    f.newLine();
    mod.stream().sorted().forEach(permWriter);
    f.newLine();
    f.write("User");
    f.write("-----");
    f.newLine();
    user.stream().sorted().forEach(permWriter);
    f.flush();
    f.close();
    src.sendMessage(plugin.getMessageProvider().getTextMessageWithFormat("command.printperms", file));
    return CommandResult.success();
}
Also used : NoModifiers(io.github.nucleuspowered.nucleus.internal.annotations.command.NoModifiers) CommandResult(org.spongepowered.api.command.CommandResult) RegisterCommand(io.github.nucleuspowered.nucleus.internal.annotations.command.RegisterCommand) CommandSource(org.spongepowered.api.command.CommandSource) BufferedWriter(java.io.BufferedWriter) PermissionInformation(io.github.nucleuspowered.nucleus.internal.permissions.PermissionInformation) FileWriter(java.io.FileWriter) NonnullByDefault(org.spongepowered.api.util.annotation.NonnullByDefault) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) RunAsync(io.github.nucleuspowered.nucleus.internal.annotations.RunAsync) Consumer(java.util.function.Consumer) List(java.util.List) AbstractCommand(io.github.nucleuspowered.nucleus.internal.command.AbstractCommand) CommandContext(org.spongepowered.api.command.args.CommandContext) Map(java.util.Map) SuggestedLevel(io.github.nucleuspowered.nucleus.internal.permissions.SuggestedLevel) Permissions(io.github.nucleuspowered.nucleus.internal.annotations.command.Permissions) FileWriter(java.io.FileWriter) IOException(java.io.IOException) Map(java.util.Map) PermissionInformation(io.github.nucleuspowered.nucleus.internal.permissions.PermissionInformation) BufferedWriter(java.io.BufferedWriter)

Aggregations

PermissionInformation (io.github.nucleuspowered.nucleus.internal.permissions.PermissionInformation)8 HashMap (java.util.HashMap)5 SuggestedLevel (io.github.nucleuspowered.nucleus.internal.permissions.SuggestedLevel)2 IOException (java.io.IOException)2 List (java.util.List)2 Map (java.util.Map)2 Lists (com.google.common.collect.Lists)1 Maps (com.google.common.collect.Maps)1 Sets (com.google.common.collect.Sets)1 Gson (com.google.gson.Gson)1 TypeToken (com.google.gson.reflect.TypeToken)1 ConfigException (com.typesafe.config.ConfigException)1 DESCRIPTION (io.github.nucleuspowered.nucleus.PluginInfo.DESCRIPTION)1 ID (io.github.nucleuspowered.nucleus.PluginInfo.ID)1 NAME (io.github.nucleuspowered.nucleus.PluginInfo.NAME)1 VERSION (io.github.nucleuspowered.nucleus.PluginInfo.VERSION)1 NucleusAPITokens (io.github.nucleuspowered.nucleus.api.NucleusAPITokens)1 NucleusMessageTokenService (io.github.nucleuspowered.nucleus.api.service.NucleusMessageTokenService)1 NucleusModuleService (io.github.nucleuspowered.nucleus.api.service.NucleusModuleService)1 NucleusWarmupManagerService (io.github.nucleuspowered.nucleus.api.service.NucleusWarmupManagerService)1