In general, I already know and I managed to create a command that creates a Fireball using "/mkt fireball <strenght>", but I think I'm doing it the wrong way: My command is "/mkt", and I'm creating others using the first argument, like "fireball". Onwards I can create a "/mkt build <shape>", with "build" being the argument. I'm pretty sure this is wrong, and that there is a way to create a command from a better command, such as "/rftdim safedel <dimId>" from RFTools Dimensions. In short, I want to implement something similar to "/rftdim" in my mod, which after that I can call my command. This shortcut is easier for the player to find out where the commands come from.
In Main.java, i am using this to register:
@EventHandler
public static void serverStarting(FMLServerStartingEvent event)
{
ModCommands.registerCommands(event);
}
Herei i register:
public class ModCommands{
public static void registerCommands(FMLServerStartingEvent event)
{
event.registerServerCommand(new BaseCommand());
}
}
And here i use the first argument to call a command, like Fireball or Build:
public class BaseCommand extends CommandBase {
@Override
public String getCommandName() {
return "mkt";
}
@Override
public String getCommandUsage(ICommandSender sender) {
return "/mkt <command>";
}
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
List<String> commands = new ArrayList<String>();
commands.add("help");
commands.add("fireball");
if (args.length > 0) {
if(args[0].equals("fireball")){
new Fireball().execute(server, sender, args);
}
}
else{
String formatted = "";
formatted += TextFormatting.BLUE;
formatted += "/mkt help";
String notFormated = "";
notFormated += TextFormatting.WHITE;
notFormated += "to help.";
sender.addChatMessage(new TextComponentString(formatted + " " + notFormated));
}
if(args.length > 0) {
if (!commands.contains(args[0])) {
String formatted = "";
formatted += TextFormatting.BLUE;
formatted += "'" + args[0] + "'";
String notFormated = "";
notFormated += TextFormatting.WHITE;
notFormated += "are not a Mekatronic command.";
sender.addChatMessage(new TextComponentString(formatted + " " + notFormated));
}
}
}
}
All my others command extends CommandBase, my BaseCommand just decides which command to call.
I tried to find out in RFToolsDim's .jar how they implemented the commands, but I'm new to java, and I don't understand anything.