syntax = "group <group> create [parents]",
permission = "permissions.manage.groups.create.<group>",
description = "Create <group> and/or set [parents]")
public void groupCreate(PermissionsEx plugin, CommandSender sender, Map<String, String> args) {
String groupName = this.autoCompleteGroupName(args.get("group"));
PermissionGroup group = plugin.getPermissionsManager().getGroup(groupName);
if (group == null) {
sender.sendMessage(ChatColor.RED + "Group \"" + groupName + "\" doesn't exist.");
return;
}
if (!group.isVirtual()) {
sender.sendMessage(ChatColor.RED + "Group \"" + args.get("group") + "\" already exists.");
return;
}
if (args.get("parents") != null) {
String[] parents = args.get("parents").split(",");
List<PermissionGroup> groups = new LinkedList<>();
for (String parent : parents) {
groups.add(plugin.getPermissionsManager().getGroup(parent));
}
group.setParents(groups, null);
}
sender.sendMessage(ChatColor.WHITE + "Group \"" + group.getIdentifier() + "\" created!");
group.save();
}