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)
@Baffu
sorry, that's not possible... it was planned for the future update but I'm not sure about author's plans atm
Is it possible to have /x excute /y,/z./q
?
@isoccerplayer
no problem at all, happens even to the best of us :-D
have fun Minecrafting!
Ah :D Lol I feel bad. I'm sorry, I should have checked the Game Version first. Anyways, it works GREAT now :D Thank you so much for all the help!
@isoccerplayer
if you tried to install the latest version, it's meant for CB 1.2.3, which is a development build... for recommended versions, which are still based on Minecraft 1.1, try using the oldest file on the right (http://dev.bukkit.org/server-mods/commander/files/2-v1-0) ... if it doesn't work for you, I'll try to build again against recommended 1.1 for you
@isoccerplayer
there is nothing to translate in this plugin, but thanks for the help offer :-)
I am currently using the recommended 1.1 Version of bukkit, on my DEV server. I saw no errors in the console... I've tried re-installing Commander a few times but still no warnings appear.
I could do the translation of this plugin in French! I am French so... PM me!
@isoccerplayer
what bukkit version are you using? this works ok for me with 1.2 server versions... do you get any errors? startup messages from Commander? (there should be few, at least info about generating new files because they were not found - in the console I mean)
@zathrus_writer
Hmmmm..... I only saw the config.yml file generated, with the content I listed earlier. I then tried to create the file myself, and used a plaintext file, with the content you listed, but it didn't seem to work. Thanks for the help so far!
@isoccerplayer
in your Commander folder, also files called playercmd.txt, playerchat.txt and consolecmd.txt should have been created
these are the files where you set up your aliases, in your case it would be file playercmd.txt
in this file, you'll put: /events/ ==> warp events
that's all :-)
Alright, I am very new to this plugin, and any help would be GREATLY Appreciated.
I downloaded Commander, and the Commander Folder was generated. Within the folder, a file called config.yml was created, with this as it's contents:
log: player: commands: false files: playercmd: playercmd.txt playerchat: playerchat.txt consolecmd: consolecmd.txt
Now, I want to be able to make a command alias, for, say, /warp events and change it to /events and when /events is typed, it will perform the function of /warp events.
Now, What would I have to write, and would I need to create a new text file, in that folder, to place the command alias list?
If you could help me with that example, as in what needs to be written, and where, I'm certain I could figure it out from there. Sorry, I am pretty confused, atm. Thanks for the help!
@eMan1200The3rd
follow-up on fixing the /commander reload command: the command is console-only and does not work from within world (i.e. when a player tries to execute it)
this is because this plugin does not check permission nodes and is not planned to... you need to use console to reload Commander
@eMan1200The3rd
I wasn't aware that reload doesn't work, will have a look at it today... thanks for the report
@jnmcraft
there are no ingame commands, only configuration files that are being read on plugin re/load
i think this is from the essentials plugin but cant you use /reload? to just reload the plugins?
Could You Please Fix The:
/commander reload
It's Starting To Piss Me Off Having To Reloading My Server Everytime!
Are there any in-game commands?
ok, I've uploaded 1.0.2 version that will work on 1.2 servers with Java 1.6+ installed
you can still get it from GitHub until Bukkit guys approve it and the file appears here (https://github.com/downloads/zathrus-writer/Bukkit-Commander/commander.jar)
Thank you!
@rmkilc
I think I know where the problem is... I used Java 7 to compile the code... will re-upload the file later today and it should work for you then
I am getting this error:
2012-03-10 10:22:30 [SEVERE] Could not load 'plugins\commander.jar' in folder 'plugins' org.bukkit.plugin.InvalidPluginException: java.lang.UnsupportedClassVersionError: org/digiplex/bukkitplugin/commander/CommanderPlugin : Unsupported major.minor version 51.0 at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:150) at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:287) at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:211) at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:207) at org.bukkit.craftbukkit.CraftServer.<init>(CraftServer.java:183) at net.minecraft.server.ServerConfigurationManager.<init>(ServerConfigurationManager.java:56) at net.minecraft.server.MinecraftServer.init(MinecraftServer.java:156) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:425) at net.minecraft.server.ThreadServerApplication.run(SourceFile:490) Caused by: java.lang.UnsupportedClassVersionError: org/digiplex/bukkitplugin/commander/CommanderPlugin : Unsupported major.minor version 51.0 at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClassCond(Unknown Source) at java.lang.ClassLoader.defineClass(Unknown Source) at java.security.SecureClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.access$000(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:41) at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:29) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Unknown Source) at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:139) ... 8 more