Search in sources :

Example 1 with AbstractCommand

use of com.builtbroken.mc.core.commands.prefab.AbstractCommand in project Engine by VoltzEngine-Project.

the class ModularCommandRemoveAdd method handleConsoleCommand.

@Override
public boolean handleConsoleCommand(ICommandSender sender, String[] args) {
    if (isHelpCommand(args)) {
        handleHelp(sender, args);
    } else {
        String username = args[0];
        if (username != null && !username.isEmpty()) {
            if (args.length > 1) {
                String command = args[1];
                String[] a = removeFront(args, 2);
                if (!remove && command.equalsIgnoreCase("to") || remove && command.equalsIgnoreCase("from")) {
                    if (args.length > 2) {
                        command = args[2];
                        a = removeFront(a);
                    } else if (remove) {
                        sender.addChatMessage(new ChatComponentText("Need to know what to remove the " + type + " from"));
                        return true;
                    } else {
                        sender.addChatMessage(new ChatComponentText("Need to know what to add the " + type + " to"));
                        return true;
                    }
                }
                for (AbstractCommand c : subCommands) {
                    if (c instanceof SubCommandWithName && c.getCommandName().equalsIgnoreCase(command) && ((SubCommandWithName) c).handleConsoleCommand(sender, username, a)) {
                        return true;
                    }
                }
                sender.addChatMessage(new ChatComponentText("Unknown sub command"));
            } else if (remove) {
                sender.addChatMessage(new ChatComponentText("Need to know what to remove the " + type + " from"));
                return true;
            } else {
                sender.addChatMessage(new ChatComponentText("Need to know what to add the " + type + " to"));
                return true;
            }
        } else {
            sender.addChatMessage(new ChatComponentText("Empty names are not permitted"));
        }
    }
    return true;
}
Also used : AbstractCommand(com.builtbroken.mc.core.commands.prefab.AbstractCommand) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 2 with AbstractCommand

use of com.builtbroken.mc.core.commands.prefab.AbstractCommand in project Engine by VoltzEngine-Project.

the class CommandGroup method getHelpOutput.

@Override
public void getHelpOutput(ICommandSender sender, List<String> items) {
    List<String> commands;
    for (AbstractCommand command : subCommands) {
        commands = new ArrayList();
        command.getHelpOutput(sender, commands);
        for (String s : commands) {
            items.add("[name] " + command.getCommandName() + " " + s);
        }
    }
}
Also used : AbstractCommand(com.builtbroken.mc.core.commands.prefab.AbstractCommand) ArrayList(java.util.ArrayList)

Example 3 with AbstractCommand

use of com.builtbroken.mc.core.commands.prefab.AbstractCommand in project Engine by VoltzEngine-Project.

the class TestAbstractCommand method testInit.

@Test
public void testInit() {
    AbstractCommand command = new AbstractCommand("command");
    assertTrue(command.getCommandName().equals("command"));
}
Also used : AbstractCommand(com.builtbroken.mc.core.commands.prefab.AbstractCommand) AbstractTest(com.builtbroken.mc.testing.junit.AbstractTest) Test(org.junit.Test)

Example 4 with AbstractCommand

use of com.builtbroken.mc.core.commands.prefab.AbstractCommand in project Engine by VoltzEngine-Project.

the class ModularCommandRemoveAdd method getHelpOutput.

@Override
public void getHelpOutput(ICommandSender sender, List<String> items) {
    List<String> commands;
    for (AbstractCommand command : subCommands) {
        commands = new ArrayList();
        command.getHelpOutput(sender, commands);
        for (String s : commands) {
            items.add("[" + type + "] " + (remove ? "from" : "to") + " " + command.getCommandName() + " " + s);
        }
    }
}
Also used : AbstractCommand(com.builtbroken.mc.core.commands.prefab.AbstractCommand) ArrayList(java.util.ArrayList)

Example 5 with AbstractCommand

use of com.builtbroken.mc.core.commands.prefab.AbstractCommand 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.framework.access.AccessGroup) AbstractCommand(com.builtbroken.mc.core.commands.prefab.AbstractCommand) ChatComponentText(net.minecraft.util.ChatComponentText) GroupSubCommand(com.builtbroken.mc.core.commands.ext.GroupSubCommand)

Aggregations

AbstractCommand (com.builtbroken.mc.core.commands.prefab.AbstractCommand)8 ArrayList (java.util.ArrayList)3 ChatComponentText (net.minecraft.util.ChatComponentText)3 AbstractTest (com.builtbroken.mc.testing.junit.AbstractTest)2 Test (org.junit.Test)2 GroupSubCommand (com.builtbroken.mc.core.commands.ext.GroupSubCommand)1 UserSubCommand (com.builtbroken.mc.core.commands.ext.UserSubCommand)1 AccessGroup (com.builtbroken.mc.framework.access.AccessGroup)1 AccessUser (com.builtbroken.mc.framework.access.AccessUser)1