use of com.builtbroken.mc.lib.access.AccessGroup in project Engine by VoltzEngine-Project.
the class CommandAddUserToRegion method handle.
@Override
public boolean handle(ICommandSender sender, Region region, String[] args) {
if (args.length > 0) {
AccessGroup group = null;
if (args.length > 1) {
String groupName = null;
if (args[1].equalsIgnoreCase("to") && args.length > 2) {
if (args[2].equalsIgnoreCase("group")) {
if (args.length > 3) {
groupName = args[3];
} else {
sender.addChatMessage(new ChatComponentText("Missing group name"));
return true;
}
}
} else if (args[1].equalsIgnoreCase("group")) {
if (args.length > 2) {
groupName = args[2];
} else {
sender.addChatMessage(new ChatComponentText("Missing group name"));
return true;
}
} else {
groupName = args[1];
}
group = region.getAccessProfile().getGroup(groupName);
} else {
group = region.getAccessProfile().getGroup("user");
}
if (group != null) {
if (group.addMember(args[0])) {
sender.addChatMessage(new ChatComponentText("User added"));
} else if (group.getMember(args[0]).getGroup() != null) {
sender.addChatMessage(new ChatComponentText("User is already part of the group"));
} else {
sender.addChatMessage(new ChatComponentText("Error adding user"));
}
} else {
sender.addChatMessage(new ChatComponentText("Not sure what group you want to add the user to"));
}
} else {
sender.addChatMessage(new ChatComponentText("Missing username"));
}
return true;
}
use of com.builtbroken.mc.lib.access.AccessGroup in project Engine by VoltzEngine-Project.
the class CommandGroup method handleConsoleCommand.
@Override
public boolean handleConsoleCommand(ICommandSender sender, String[] args) {
String name = args[0];
AccessGroup group = GroupProfileHandler.GLOBAL.getAccessProfile().getGroup(name);
if (group != null) {
if (args.length > 1) {
for (AbstractCommand command : subCommands) {
if (command instanceof GroupSubCommand && command.getCommandName().equalsIgnoreCase(args[1])) {
if (((GroupSubCommand) command).handle(sender, group, "", removeFront(args, 2))) {
return true;
}
}
}
}
sender.addChatMessage(new ChatComponentText("Unknown group sub command"));
} else {
sender.addChatMessage(new ChatComponentText("Unknown group"));
}
return true;
}
Aggregations