Search in sources :

Example 6 with AccessGroup

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;
}
Also used : AccessGroup(com.builtbroken.mc.lib.access.AccessGroup) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 7 with AccessGroup

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;
}
Also used : AccessGroup(com.builtbroken.mc.lib.access.AccessGroup) AbstractCommand(com.builtbroken.mc.prefab.commands.AbstractCommand) ChatComponentText(net.minecraft.util.ChatComponentText) GroupSubCommand(com.builtbroken.mc.core.commands.ext.GroupSubCommand)

Aggregations

AccessGroup (com.builtbroken.mc.lib.access.AccessGroup)7 ChatComponentText (net.minecraft.util.ChatComponentText)5 AccessProfile (com.builtbroken.mc.lib.access.AccessProfile)2 GroupSubCommand (com.builtbroken.mc.core.commands.ext.GroupSubCommand)1 AbstractCommand (com.builtbroken.mc.prefab.commands.AbstractCommand)1