Synonym - A regex-based command alias plugin

This is a discussion topic for the Ore project, Synonym. View the full project on Ore for downloads and more information.


Synonym

NOTE: I am aware that something about the replacements does not work. I am trying to find a solution.

Synonym is a Sponge command alias plugin based around regular expression. It’s somewhat powerful, but may require a little to work to really start cooking. If you CBA to read the wikipedia page, click here.

Config

aliases[]: This is essentially the root node, but it’s a list to preserve order - the first to match is used. It’s a list of alias compound nodes.
Within an alias tag:
cmd: This is the alias which will be run. It’s a regex match.
replacement: This is the command that the alias represents. It can contain capture groups (read the \n section here, but with $ instead of ‘\’) from cmd. It can also hold variables, discussed below.
vars{}: This is an optional block which holds various variables which are essentially a finite list of possible matchings for a given section. It contains variable nodes, named by how they appear in replacement (or even in cmd if you really want to do that).
Within a variable node:
text: This is the text that the variable’s conditions will match against. This should contain at least one capture group from cmd.
options[] This is a list of option compound nodes. The order has the same meaning as alias nodes - the first to match, wins.
Within an option node:
option: This is regex text that is tested to match text. If it does, then this option is the one that is selected.
value: If this option is selected, then the variable will be replaced with this text.
match: value can contain capture groups. If set to cmd then the capture groups from cmd are used; if set to option, then the capture groups from option are used.

Note that any regex you see on the wiki or on the rundown page involving a backslash ‘’ should actually be used with two backslashes ‘\’ since HOCON uses backslashes too. A backslash-escaped backslash ‘\’ would be written as four backslashes ‘\\’.

It’s a somewhat complex config to understand just from this description, so I’d recommend taking a look at the default configuration. Using it, /gm <x> turns into /gamemode <x>, and /tell Notch <anything> is turned into /kill, but leaving untouched `/tell .

Changelog

1.0.0: $1
1.0.1: Fixed potential bug

4 Likes

A new version has been released for Synonym, it is available for download here.


Fixed potential bug

I was wondering what the proper syntax would be for replacing something like “/warp shop” with “/shop”.

1 Like
aliases = [
    {
        cmd = "^shop"
        replacement = "warp shop"
    }
]

Is it possible to reload this plugin?

I’ll add that in the next release, but a couple of people have told me that specific configurations won’t work, and priority is fixing that.

is there a way to make alias commands be ran by the console? by that I’m looking at trying to give someone a command like
/setgymleader water - alias
but the console run /perm user parent add watergymleader

(so that i dont have to give the person free range access to adding players to groups)

Same as I told @Gershon.

this? or next update? not clear on which post.
What about perm nodes of its own? and are they still required to have the base perms of the plugin?

Well, only one of those posts was actually a reply to Gershon.

And I’ll add permission nodes too.

I’m dumb so yeah next update. looking forward to it! and thank you for creating an alias plugin

i tried the example shop thing as a simple test to see if i was doing things right and its just unknown commands. does this support /sponge plugins reload or does it require a server restart?

It requires a server restart for changes to take effect, though I’ll add reloading in the next release.

slashes (/) can’t be used as an alias?

They’re not used at all (unless the command itself contains them, such as WorldEdit).

i wasnt able to get the example command above to even load after a restart.

This plugin was created really quickly, and I didn’t test it very much. I probably released it too soon, but there’s no ‘disable plugin’ button on Ore.