Search in sources :

Example 1 with AbstractCommand

use of com.builtbroken.mc.prefab.commands.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.prefab.commands.AbstractCommand) AbstractTest(com.builtbroken.mc.testing.junit.AbstractTest) Test(org.junit.Test)

Example 2 with AbstractCommand

use of com.builtbroken.mc.prefab.commands.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.prefab.commands.AbstractCommand) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 3 with AbstractCommand

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

the class CommandRegion 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.prefab.commands.AbstractCommand) ArrayList(java.util.ArrayList)

Example 4 with AbstractCommand

use of com.builtbroken.mc.prefab.commands.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.prefab.commands.AbstractCommand) ArrayList(java.util.ArrayList)

Example 5 with AbstractCommand

use of com.builtbroken.mc.prefab.commands.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.prefab.commands.AbstractCommand) ArrayList(java.util.ArrayList)

Aggregations

AbstractCommand (com.builtbroken.mc.prefab.commands.AbstractCommand)10 ArrayList (java.util.ArrayList)4 ChatComponentText (net.minecraft.util.ChatComponentText)4 AbstractTest (com.builtbroken.mc.testing.junit.AbstractTest)2 Test (org.junit.Test)2 GroupSubCommand (com.builtbroken.mc.core.commands.ext.GroupSubCommand)1 SubCommandRegion (com.builtbroken.mc.core.commands.ext.SubCommandRegion)1 UserSubCommand (com.builtbroken.mc.core.commands.ext.UserSubCommand)1 AccessGroup (com.builtbroken.mc.lib.access.AccessGroup)1 AccessUser (com.builtbroken.mc.lib.access.AccessUser)1 Region (com.builtbroken.mc.lib.modflags.Region)1