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;
}
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);
}
}
}
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"));
}
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);
}
}
}
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;
}
Aggregations