equivalent-exchange-3/ee3_common/com/pahimar/ee3/command/CommandEE.java

86 lines
3.4 KiB
Java
Raw Normal View History

package com.pahimar.ee3.command;
import java.util.List;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.command.WrongUsageException;
import com.pahimar.ee3.lib.Commands;
public class CommandEE extends CommandBase {
public String getCommandName() {
return Commands.COMMAND_EE3;
}
public boolean canCommandSenderUseCommand(ICommandSender commandSender) {
return true;
}
public List addTabCompletionOptions(ICommandSender commandSender, String[] args) {
2012-12-31 02:42:27 +01:00
switch (args.length) {
case 1: {
return getListOfStringsMatchingLastWord(args, new String[] { Commands.COMMAND_OVERLAY, Commands.COMMAND_PARTICLES, Commands.COMMAND_SOUNDS });
2012-12-31 02:42:27 +01:00
}
case 2: {
if (args[0].equalsIgnoreCase(Commands.COMMAND_OVERLAY)) {
return getListOfStringsMatchingLastWord(args, new String[] { Commands.COMMAND_ON, Commands.COMMAND_OFF, Commands.COMMAND_POSITION, Commands.COMMAND_SCALE, Commands.COMMAND_OPACITY });
2012-12-31 02:42:27 +01:00
}
else if (args[0].equalsIgnoreCase(Commands.COMMAND_PARTICLES)) {
return getListOfStringsMatchingLastWord(args, new String[] { Commands.COMMAND_ON, Commands.COMMAND_OFF });
2012-12-31 02:42:27 +01:00
}
else if (args[0].equalsIgnoreCase(Commands.COMMAND_SOUNDS)) {
return getListOfStringsMatchingLastWord(args, new String[] { Commands.COMMAND_ALL, Commands.COMMAND_SELF, Commands.COMMAND_OFF });
}
2012-12-31 02:42:27 +01:00
}
case 3: {
if (args[0].equalsIgnoreCase(Commands.COMMAND_OVERLAY)) {
if (args[1].equalsIgnoreCase(Commands.COMMAND_POSITION)) {
return getListOfStringsMatchingLastWord(args, new String[] { Commands.COMMAND_TOP, Commands.COMMAND_BOTTOM });
2012-12-31 02:42:27 +01:00
}
}
}
case 4: {
if (args[0].equalsIgnoreCase(Commands.COMMAND_OVERLAY)) {
if (args[1].equalsIgnoreCase(Commands.COMMAND_POSITION)) {
if (args[2].equalsIgnoreCase(Commands.COMMAND_TOP) || args[2].equalsIgnoreCase(Commands.COMMAND_BOTTOM)) {
return getListOfStringsMatchingLastWord(args, new String[] { Commands.COMMAND_LEFT, Commands.COMMAND_RIGHT });
2012-12-31 02:42:27 +01:00
}
}
}
}
default: {
return null;
}
}
}
public void processCommand(ICommandSender commandSender, String[] args) {
if (args.length > 0) {
String commandName = args[0];
System.arraycopy(args, 1, args, 0, args.length - 1);
if (commandName.equalsIgnoreCase(Commands.COMMAND_OVERLAY)) {
2012-12-21 03:31:59 +01:00
CommandOverlay.processCommand(commandSender, args);
}
else if (commandName.equalsIgnoreCase(Commands.COMMAND_PARTICLES)) {
2012-12-21 03:31:59 +01:00
CommandParticles.processCommand(commandSender, args);
}
else if (commandName.equalsIgnoreCase(Commands.COMMAND_SOUNDS)) {
CommandSounds.processCommand(commandSender, args);
}
else {
throw new WrongUsageException(Commands.COMMAND_EE3_USAGE, new Object[0]);
}
}
else {
throw new WrongUsageException(Commands.COMMAND_EE3_USAGE, new Object[0]);
}
}
}