description = "Set <group> for <user>")
public void userSetGroup(PermissionsEx plugin, CommandSender sender, Map<String, String> args) {
String userName = this.autoCompletePlayerName(args.get("user"));
String worldName = this.autoCompleteWorldName(args.get("world"));
PermissionManager manager = plugin.getPermissionsManager();
PermissionUser user = manager.getUser(userName);
if (user == null) {
sender.sendMessage(ChatColor.RED + "User \"" + userName + "\" doesn't exist.");
return;
}
String groupName = args.get("group");
List<PermissionGroup> groups;
if (groupName.contains(",")) {
String[] groupsNames = groupName.split(",");
groups = new ArrayList<>(groupsNames.length);
for (String addName : groupsNames) {
if (sender instanceof Player && !manager.has((Player) sender, "permissions.manage.membership." + addName.toLowerCase())) {
sender.sendMessage(ChatColor.RED + "Don't have enough permission for group " + addName);
return;
}
groups.add(manager.getGroup(this.autoCompleteGroupName(addName)));
}
} else {
groupName = this.autoCompleteGroupName(groupName);
if (groupName != null) {
groups = Collections.singletonList(manager.getGroup(groupName));
if (sender instanceof Player && !manager.has((Player) sender, "permissions.manage.membership." + groupName.toLowerCase())) {
sender.sendMessage(ChatColor.RED + "Don't have enough permission for group " + groupName);
return;
}
} else {