use of org.spongepowered.api.service.permission.SubjectData in project Nucleus by NucleusPowered.
the class SetupPermissionsCommand method setupPerms.
private void setupPerms(CommandSource src, Subject group, SuggestedLevel level, boolean reset, boolean inherit) throws Exception {
if (inherit && level.getLowerLevel() != null) {
setupPerms(src, group, level.getLowerLevel(), reset, inherit);
}
Set<Context> globalContext = Sets.newHashSet();
SubjectData data = group.getSubjectData();
Set<String> definedPermissions = data.getPermissions(ImmutableSet.of()).keySet();
Logger logger = Nucleus.getNucleus().getLogger();
MessageProvider messageProvider = Nucleus.getNucleus().getMessageProvider();
// Register all the permissions, but only those that have yet to be assigned.
permissionRegistry.getPermissions().entrySet().stream().filter(x -> x.getValue().level == level).filter(x -> reset || !definedPermissions.contains(x.getKey())).forEach(x -> {
logger.info(messageProvider.getMessageWithFormat("command.nucleus.permission.added", x.getKey(), group.getIdentifier()));
data.setPermission(globalContext, x.getKey(), Tristate.TRUE);
});
src.sendMessage(plugin.getMessageProvider().getTextMessageWithFormat("command.nucleus.permission.complete", level.toString().toLowerCase(), group.getIdentifier()));
}
Aggregations