BloodMagic/src/main/java/WayofTime/bloodmagic/command/CommandBloodMagic.java

78 lines
2.3 KiB
Java
Raw Normal View History

package WayofTime.bloodmagic.command;
import WayofTime.bloodmagic.command.sub.SubCommandBind;
import WayofTime.bloodmagic.command.sub.SubCommandHelp;
import WayofTime.bloodmagic.command.sub.SubCommandNetwork;
import WayofTime.bloodmagic.command.sub.SubCommandOrb;
import WayofTime.bloodmagic.util.helper.TextHelper;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.text.TextComponentString;
import java.util.*;
2016-03-16 22:41:06 +00:00
public class CommandBloodMagic extends CommandBase
{
// TODO - Move this and sub commands to CommandTreeBase in 1.11. Much cleaner impl
private final List<String> aliases = new ArrayList<String>();
private final Map<String, ISubCommand> subCommands = new HashMap<String, ISubCommand>();
2016-03-16 22:41:06 +00:00
public CommandBloodMagic()
{
aliases.add("BloodMagic");
aliases.add("bloodmagic");
aliases.add("bloodMagic");
aliases.add("bm");
subCommands.put("help", new SubCommandHelp(this));
subCommands.put("network", new SubCommandNetwork(this));
subCommands.put("bind", new SubCommandBind(this));
subCommands.put("orb", new SubCommandOrb(this));
}
@Override
2016-03-16 22:41:06 +00:00
public String getCommandName()
{
return "/bloodmagic";
}
@Override
2016-03-16 22:41:06 +00:00
public int getRequiredPermissionLevel()
{
return 2;
}
@Override
2016-03-16 22:41:06 +00:00
public String getCommandUsage(ICommandSender commandSender)
{
return getCommandName() + " help";
}
@Override
2016-03-16 22:41:06 +00:00
public List<String> getCommandAliases()
{
return aliases;
}
@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args)
2016-03-16 22:41:06 +00:00
{
if (args.length > 0 && subCommands.containsKey(args[0]))
{
ISubCommand subCommand = subCommands.get(args[0]);
String[] subArgs = Arrays.copyOfRange(args, 1, args.length);
subCommand.processSubCommand(server, commandSender, subArgs);
2016-03-16 22:41:06 +00:00
} else
{
commandSender.addChatMessage(new TextComponentString(TextHelper.localizeEffect("commands.error.unknown")));
}
}
2016-03-16 22:41:06 +00:00
public Map<String, ISubCommand> getSubCommands()
{
return subCommands;
}
}