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));
}
};
}
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;
}
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;
}
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());
});
}
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();
}
Aggregations