Edit:
Found the solution to my problem. Thank to @Redrield.
Also, thanks to https://docs.spongepowered.org/master/en-GB/plugin/commands/childcommands.html
Spongedocs are very well put together.
Hey everyone. I’m doing command arguments right now, and I have a question about how to do something.
I want to create a centralized command (eg. /cmd ) the “cmd” would be the centralized command with arguments such as “home” or “sethome”. How would I go about doing that?
Main Class:
@Plugin(id="mcs", name="MCS", version="0.0.1")
public class MCS
{
@Listener
public void onServerStarting(GameStartingServerEvent event)
{
// Primary Command Registration
CommandSpec mcsCommandSpec = CommandSpec.builder()
.description(Text.of("MCS Command"))
.permission("mcs.homes")
.executor(new CommandManager())
.build();
Sponge.getCommandManager().register(this, mcsCommandSpec, "mcs");
}
}
CommandManager Class:
public class CommandManager implements CommandExecutor
{
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException
{
if (src instanceof ConsoleSource)
{
src.sendMessage(Text.of("This command can only be used in-game!"));
return CommandResult.empty();
}
return CommandResult.success();
}
}
This is a very different api from craftbukkit or spigot, this is for learning.
Thank you,
- ST