Commander
Ever wanted to make an alias for those really long commands you have to type out constantly? Want to give players a simple one word command to warp somewhere? Want to create advanced scripts that run when you type a command? Want to clean up the server chat a bit?
Commander can do all that for you!
Commander is a find-replace plugin for commands and chat. It uses regular expressions to search player commands, player chat, or even console commands and replaces any matches with specified replacements! It even supports back references!
Commander is also a scripting language (Coming Soon!) which allows a single command to fire off a set of commands, with if statements and while loops and function calls! Oh my!
How it works
Commander examines player commands and server commands before proper processing of the commands even begins. It will use a list of regular expressions provided in the configuration folder and attempt to match the regex to the whole command. If it matches, it will replace the command with the specified replacement, be it a single command or a script!
For chat, it will attempt to find the regex in the chat somewhere, and replace the matched words with the specified replacement. Commander will even check if the word it found is in all caps, and, if it is, make the replacement in all caps as well! It also supports Command Words, which will fire off a command or script when the regex matches a word in the chat!
A Note about Permissions
Commander does not use permissions when matching, and there are no plans to make it use permissions. Commander simply finds and replaces the command regardless of permission status. There are also no permissions to bypass replacement - it will replace for all players regardless of permission status. If you wish to deny access to a command, you must deny access to the replacement. Note also: Players will not see the replacement command, they will only know what they entered worked or did not work.
Commander, however, does have support for Bukkit's built-in permissions in script (Coming Soon!). If you want to deny your players access to a command which fires off a script, you can put an if statement that checks if the current player has the proper permission!
Example Configuration
When you start up the plugin for the first time, Commander will place 3 text files in its data folder along with the config.yml. There is one file for each replacement context: player commands, player chat, and console commands. The following is the default player command file:
/cmode/ ==> gamemode $p 1 /smode/ ==> gamemode $p 0 /promote (.*)/ ==> pex promote $1 /demote (.*)/ ==> pex demote $1
The format is as follows: /find regex/ ==> replacement
The find regex is denoted by forward slashes (/). The replacement comes after the double equals arrow (==>).
Java regular expressions are fully supported (minus the escaping the backslash malarkey) and a guide to java regexes can be found here.
In the replacement string, the dollar sign ($) signifies a back reference to a capture group in the regex. Special back references can also be used relating to the player issuing them. The list of back references is as follows:
- $0 - $9 = back reference to a capture group in the regex (following java's model)
- $p = player name (not display name, but normal name)
- ....more to come....
Version 2.0 BETA
Version 2.0 is the advanced scripting overhaul. It is currently in alpha and may be unstable. However, while developing the scripting, I made sure all unit tests pass every time I change something, so there is the distinct possibility that all will work perfectly fine for your needs!
A comprehensive scripting reference guide can be found in the Pages tab!
Version 2.0 also adds an API for those who wish to use Commander's scripting language in their own plugin!
Version 1.2
(Yes, I realize now that I skipped version 1.1, because I thought zathrus's update was 1.1, when it was 1.0.1) Version 1.2 adds scripting!! Yay! To script, do this:
/regex/ =={ commands }
Version 1.2 also adds a helpful Reference.txt that gets copied to your data folder. There, it will explain in detail all the new changes that have taken place!
Known Bugs
- Command words (regexes matching against the chat which execute commands) run the commands before the chat message is broadcast, instead of afterward. The commands are still run in response to what you say in chat, it just doesn't seem like it...
- The [cutoff] parameter does not work properly due to the way it executes the command given to it. Due to this, cutoff will only work properly if the replacement word or phrase is the first or only thing said in the chat.+
- When parsing a script, the plugin will not detect uneven braces when there are too many open braces. This leads to commands after the orphaned open bracket not executing, as well as causing far more than just that script to be parsed as a script.+
- Backslashes, which are supposed to escape special characters, in fact remove the character they are supposed to escape.+
+ This has been fixed in the advancedScripting branch of development.
Planned Features
- More special replacement back references
- Advanced Scripting (in progress)
- Player persistent variables (session only). (for Version 2.0)
Heya guys, gorgeous plugin. I'm looking for a way to shorten channel commands, and so I put it in the playerchat.txt that if you type g: it runs the command /ch g. Works beautifully, except i find that it then makes you say "g:" after having joined the channel. Is there any way to simply remove the fact that there was a chat message? Or is there perhaps an easier way to set this up or run it in such a way?
Thanks in advance.
@tustin2121
Can I ask a quick question, is there a format code to start a new line in an echo like "\n"?
/\bhack/ =c=> echo §cSuspect a player? Please report them at §a§nwww.LihP.us/report
Also, would you consider making a bungee proxy version of this plugin?
@Shadowhackercz
That's pretty impressive, since this plugin has been around for X+2 years.
@LihPeu
Yeah, it's good.. But this feature have bukkit for X years already..
This plugin is excellent, I have used it for years and never had a problem!
The feature we value most is the chat replacements, we detect common words that new players often say like "how" and "help" and send them a message with links to our information reference. It's like a member of staff that never sleeps!
@MuhsinunCool
But me personally I don't like this plugin I don't understand it and there is no help! D: I found another one that I like http:dev.bukkit.org/bukkit-plugins/commandrunner/! :D
GUYS! YOU HAVE TO GO IN THE CONSOLE AND GO TO THE FOLDER OF THE PLUGIN AND KEEP TYPING commander reload IN THE CONSOLE UNTIL IT SAYS scripts.txt could not be found! THEN YOU HAVE TO GO TO THE FOLDER AND RIGHT CLICK CREATE NEW TEXT DOCUMENT AND NAME IT AS scripts THEN YOU HAVE TO DO commander reload IN THE CONSOLE AGAIN! NOW EVERYTHING IS SET UP! GAWD!
can you please show me example config? cuz my config.yml is empty :(
Hi, love the plugin.
Just wondering if there's any way to stop the button config from resetting?
Nice plugin!
Would be great if you can hide the commands messages like warping...
For example, instead of using "warp pvp" I set up "pvp" command, but if you use /pvp, you will recieve a message saying "warping to..."
That would be nice if you can hide that messages!
Im trying to make this work with pitemmenu.
To open a manu the command is "itemmenu open (menuName)" and if i type it in chat it works. but when i use this plugin it doesnt work, It opens the menu but the items inside dont work. Can you fix this?
The latest spigot/CB Builds break parts of this plugin. I would greatly appreciate if this plugin was updated, since it is amazing!
@tustin2121
no error in logs. only this one in chat. build #2918, the last 1.6.4 rb
@judam
I take it this is in a new version of Bukkit? A stack trace would be lovely too, though I think I already know what the problem is.
made alias for essential's /tpaccept it gives this error when i try to use it
Error: org.digiplex.bukkitplugin.commander.scripting.EchoControlPlayer.getHealth()D
@dockey67
Is there something you have in mind? I mean the way Commander works, it really has no ties to any features in minecraft itself; it's a complex command text replacement plugin, essentially. If people want to use a new command, for example, they just create a new replacement for it. Aside from maybe environment variables (which given lack of help requests for it, does seem to be used much), it kinda doesn't need updating. Certainly no one's complained that it broke in any latest update, which both surprises and pleases me.
Also, I've been very out of the minecraft loop recently. I heard that there are horses now, which blew my mind. And that's about the extent of interaction I've had with the game over the past few months. So unless someone urgently suggests something or cries that it is broken, don't expect any updates.
@tustin2121
Theres been so many updates 1.3.2 1.4.1 1.4.2 1.4.3 1.4.5 1.4.6 1.5.1 1.5.2 1.6.1 1.6.2 1.6.4 Maybe update to go with some new additions to mc
@bgarness
Thanks, I'll try that!
@Corsicaman
Here is the way that I reload commander.
Add the following new lines to your playercmd.txt (Located in the /plugins/commander folder).
This creates 2 aliases that you can use in order to reload and enable debugging on commander.
Here is a full example of my playercmd.txt:
As you can see.... I have 3 custom directives in my config file.
/zzre for reloading
/zzde for debugging commander
and finally I have over-ridden the give command. example: /give playername stone 20
Alerts all players, that this user is cheating. Starves the player. Smites the player. Provides a funny msg to the player only (The last line containing echo).
Hope this helps get you rolling!
cheater alert and minor punishment.
@miner9243
There's not enough info here for me to simply say what's wrong; the replacements at first glance look fine. If there's something wrong while loading your replacement files, Commander will tell you in the console log on startup. That being said, make sure Commander is actually installed, and is being loaded (again, check your console logs).
@michaeldriskell @Baffu
Is there something wrong with the plugin? Or has Minecraft updated recently? I haven't played for a few months now.