public boolean execute(MessageEvent event) {
String[] args = event.getMessage().split(" ");
if (args.length >= 1) {
if (args[1].toLowerCase().equals("addu")) {
if (args.length == 4) {
User u = event.getBot().getUserChannelDao().getUser(args[2]);
Group g = manager.getGroupByName(args[3]);
if (manager.getUserGroup(event.getUser()).getInheritance().contains(g.getName())) {
if (u != null) {
g.addUser(u, "*@" + u.getHostmask());
event.getUser().send().notice("Granted access to group " + g.getName() + " to user " + u.getNick());
} else {
event.getUser().send().notice("Couldn't find the user " + args[2]);
return true;
}
} else {
event.getUser().send().notice(Colors.RED + "You can't give someone a group higher than you!");
}
} else {
event.getUser().send().notice("Syntax: manager addu <user> <group>");
}
}
if (args[1].toLowerCase().equals("addp")) {
if (args.length == 4) {
Permission permission = new Permission(args[2], false);
Group group = manager.getGroupByName(args[3]);
if (group != null) {
if (manager.getUserGroup(event.getUser()).hasPermission(permission)) {
group.addPermission(permission);
event.getUser().send().notice("Added permission " + permission.getPermission() + " to group " + group.getName());
} else {
event.getUser().send().notice(Colors.RED + "You can't give someone a permission you don't have!");
}
} else {
event.getUser().send().notice("Couldn't find the group " + args[3]);
return true;
}
} else {
event.getUser().send().notice("Syntax: manager addp <permission> <group> ");
}
}
if (args[1].toLowerCase().contains("delp")) {
if (args.length == 4) {
Permission permission = new Permission(args[2], false);
Group group = manager.getGroupByName(args[3]);
Group usergroup = manager.getUserGroup(event.getUser());
if (group != null) {
if (usergroup.hasPermission(permission) && usergroup.getInheritance().contains(group.getName()) || usergroup == group) {
group.removePermission(permission.getPermission());
} else {
event.getUser().send().notice(Colors.RED + "You can't remove permissions from a group higher than you!");
}
} else {
event.getUser().send().notice("Couldn't find the group " + args[3]);
return true;
}
} else {
event.getUser().send().notice("Syntax: manager delp <permission> <group> ");
}
}
if (args[1].toLowerCase().contains("delu")) {
//delete user args[3] from group args[2]
if (args.length == 4) {
User u = event.getBot().getUserChannelDao().getUser(args[2]);
Group g = manager.getGroupByName(args[3]);
if (manager.getUserGroup(event.getUser()).getInheritance().contains(g.getName())) {
if (u != null) {
g.getUsers().remove(u);
event.getUser().send().notice("Removed access to group " + g.getName() + " from " + u.getNick());
} else {
event.getUser().send().notice("Couldn't find the user " + args[2] + " are they online?");
return true;
}
} else {