Overwriting built-in commands via global.conf

One of the plugins I’m porting from Bukkit has a /title command. Sponge also apparently has a /title command that is being called instead of my custom command.

I read here: Overriding built-in commands · Issue #633 · SpongePowered/SpongeAPI · GitHub that I can use the sponge configuration to tell Sponge what plugin to send commands to in the case of a conflict.

I am assuming that the commenter on that page meant the file described here:
https://docs.spongepowered.org/ar/server/getting-started/configuration/sponge-conf.html

In this file, the following can be seen:

commands {
    # A mapping from unqualified command alias to plugin id of the plugin
    # that should handle a certain command
    aliases=null
}

However it gives no information on what aliases actually should be in the case that the server operator needs to use it. Does anyone know how this field should be used, or any documentation that might point me in the right direction?

The title command belongs to Minecraft, not Sponge.

In short, the command alias system is that every command has a modId and commandName, so in the case of the title command, it’s minecraft:title. In this case, you’ll want to use myPlugin:title where the command name is title and the plugin’s actual id is com.myPlugin.

To actually map this correctly however, you’ll want the mapping to look like so in the config (if I’m understanding this correctly):

commands {
    # A mapping from unqualified command alias to plugin id of the plugin
    # that should handle a certain command
    aliases= {
        title: com.myPlugin
    }
}
2 Likes

That’s exactly what I was looking for, thanks!

For anyone else who finds this and is trying to figure it out, this is my plugin ID:

@Plugin(id="SpongeTest", name="Sponge Test", version="1.0")

And this is what I added/modified to the global.conf to get it to properly override the /title command:

aliases= {
    title: SpongeTest
}
2 Likes

That doc was very recently written, and I’m still working on a Table of definitions to go with it - Docs PR #291
We hope to have a more detailed explanation available shortly. A working example helps greatly, thanks!

No problem! I see that the page in question has now been updated to include a very helpful definitions section.

1 Like

would it be accurate that this is the proper structure for this?

commands {
    aliases {
        unlock=Keys
        vanish=Vanish
    }

or would it be like:
commands {
aliases {
unlock=Keys;
vanish=Vanish
}

interesting but don’t quite understand this I tried making an alias for a command but didn’t work
what I tried was repair = fix

This isn’t for creating aliases, it’s defining mappings of a command to the plugin implementing it. If, for example, say you have two plugins with a /repair command.

aliases {
    repair="nucleus"
}

This tells Sponge that the command /repair should be controlled by Nucleus (nucleus being the plugin id).

In your case, you’re looking to set up an alias for a command; not redirect it to a plugin. There are a couple of plugins that can handle aliases, one of which is my plugin CmdControl. There’s plenty of resources to help get you started, and I think this is what you’re looking for and then some.

As a final note, it’s generally better to create a new thread than bump really old ones - this was posted well over 2 years ago!