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)
i dont know what im doing wrong. here is my playercmd.txt:
/spawn/ ==> mainspawn /mv spawn/ ==> spawn
and it says /spawn is unknown command. /mv spawn is unknown command to. plz help
@michaeldriskell
It likley does not need one and stil works fine.
UPDATE!!
@CageCreeper
Commander simply manipulates input, so, in the end, the player needs the permission to actually execute the command the alias makes. So there is no way to make a player have a permission to ONLY the alias, because at some point the alias gets turned into the actual command.
That being said, look into the "sudo" prepend. If you can run warp commands from the server console (which I imagine most warp plugins wouldn't support) then you can set up something so that when the player enters the alias, it generates a console command which does the actual warping.
If I don't want players to have permissions to warp, how can I make them ONLY have permission for an alias?
1:10:50 AM [SEVERE] Error occurred while enabling Commander v2.0_ALPHA (Is it up to date?) java.lang.NullPointerException at org.digiplex.bukkitplugin.commander.CommanderPlugin.checkListFile(CommanderPlugin.java:138) at org.digiplex.bukkitplugin.commander.CommanderPlugin.loadLists(CommanderPlugin.java:109) at org.digiplex.bukkitplugin.commander.CommanderPlugin.onEnable(CommanderPlugin.java:67) at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:217) at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:457) at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:382) at org.bukkit.craftbukkit.v1_6_R2.CraftServer.loadPlugin(CraftServer.java:286) at org.bukkit.craftbukkit.v1_6_R2.CraftServer.enablePlugins(CraftServer.java:268) at net.minecraft.server.v1_6_R2.MinecraftServer.l(MinecraftServer.java:319) at net.minecraft.server.v1_6_R2.MinecraftServer.f(MinecraftServer.java:296) at net.minecraft.server.v1_6_R2.MinecraftServer.a(MinecraftServer.java:256) at net.minecraft.server.v1_6_R2.DedicatedServer.init(DedicatedServer.java:164) at net.minecraft.server.v1_6_R2.MinecraftServer.run(MinecraftServer.java:397) at net.minecraft.server.v1_6_R2.ThreadServerApplication.run(SourceFile:582)
I know its not needed but can you recompile it with 1.5.2, just so its optimized and stuff :)
@lucke_ihf
Yep, you're definitely looking for the other plugin called Commander. My plugin doesn't do that. I can't help you, I don't maintain that plugin, so do another search, and this time read the description to make sure it's the plugin you want.
What's the other plugin? But other server have this like when you click on button i says you have been healed. I typed /com add o /heal and the button doesn't heal non op players that's the problem?
@lucke_ihf
@lucke_ihf
No idea what you're talking about. You're probably looking for the *other* Commander plugin. This plugin does chat and command aliasing, not in-world items.
When I click on button it says you don't have permission to do that?
plz help, when i type /com add p /heal, and I deop myself it says you don't have permission to do that. What's the problem and what do I type?
How does the reload command work?
When I type /commander reload, it displays: "/commander [reload:debug]"
I didnt take a very close look, i only had problems as your implementation seems to miis at least the sendsound method. I think if you only replace player objects once and very early it shouldnt be a problem. However i also know plugins which frequently replace the player object and causing issues by that.
An alternative solution, but which is probably not that better, would be to listen for the packets send by the server to the player via protocollib. However, as long as you only replace player objects once per player session it should be fine.. I guess there would probably also a solution for this via reflection to only modify the method of the player class you need, removing the need for you to update whenever something else changes.
@blablubbabc
I am aware that the plugin is a bit outdated. This is what happens when the plugin developer gets a job and all.
However, my "reimplimentaion" of the Player object is simply a pass through for all methods except the message sending method. (Oooh, Proxy... *thinks*). It does this simply for echo control. I would imagine that any gaming plugin wouldn't find it broken (again, assuming it is up to date) except for the possibility that messages might not be echoed to the player if that gaming plugin grabs the player object via a command which the server admin put into an "echo off" script.
How might you go about implementing echo suppression since you highly recommend not reimplimenting the Player object?
This plugin is outdated (your Player implemantation is not up to date with bukkits Player interface (for example playSound is broken as far as I can tell)) .
Also I would recommend to NOT overwrite bukkits Player objects with your own implemantation cause this can under several circumstances break many plugins which rely on things like storing Player objects, making it incompatible to many common minigame plugins for example..
Is it possible to make the plugin run an SQL when using a command? Would be awesome.
@deleted_7919568
You can display a message back to the player who issued the command by using the "echo" command built into Commander. This command bypasses any echo suppression.
@FateMC
You've got the wrong plugin. I don't register the Player Move event, and I don't have a version 1.6. I think you're looking for the OTHER "Commander", which assigns commands to redstone generating blocks (switches, plates) and signs.
What the... http://aikar.co/timings.php?url=5700515/
My server was lagging completely with 60/100 players on, glad I found this out. Please let me know once fixed so I can stop using my alternate.