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)

You must login to post a comment. Don't have an account? Register to get one!

  • Avatar of MuhsinunCool MuhsinunCool Oct 24, 2014 at 21:50 UTC - 0 likes

    @MuhsinunCool: Go

    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

  • Avatar of MuhsinunCool MuhsinunCool Oct 24, 2014 at 21:47 UTC - 0 likes

    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!

  • Avatar of SebiXII SebiXII May 19, 2014 at 12:33 UTC - 0 likes

    can you please show me example config? cuz my config.yml is empty :(

    1. For automatically updating updater: auto-check: true auto-install: false
    1. For sending anonymous usage data to us for future improvements metrics: enable: true only this
  • Avatar of Redmag3 Redmag3 Apr 02, 2014 at 00:09 UTC - 0 likes

    Hi, love the plugin.

    Just wondering if there's any way to stop the button config from resetting?

  • Avatar of XarlyAlways XarlyAlways Mar 28, 2014 at 21:44 UTC - 0 likes

    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!

  • Avatar of cuvthe3rd cuvthe3rd Feb 15, 2014 at 11:43 UTC - 0 likes

    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?

  • Avatar of MelonCraftServer MelonCraftServer Dec 31, 2013 at 03:14 UTC - 0 likes

    The latest spigot/CB Builds break parts of this plugin. I would greatly appreciate if this plugin was updated, since it is amazing!

    MelonCraft Network - Ultimate Hybrid Server: Factions, Creative, TF2, Paintball, Splegg, Parkour, Hunger Games, Zombies, OITC, TNTRun CTF, KitPvP, and just about everything else there is.

    http://meloncraft.com

  • Avatar of judam judam Nov 13, 2013 at 03:38 UTC - 0 likes

    @tustin2121: Go

    no error in logs. only this one in chat. build #2918, the last 1.6.4 rb

    Last edited Nov 13, 2013 by judam
  • Avatar of tustin2121 tustin2121 Nov 13, 2013 at 02:15 UTC - 0 likes

    @judam: Go

    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.

    Hey! Do you own a popular server that gets bombarded with WHAT HAPPENED TO THE SERVER HURBLUB&$%?!?!11?!?! when it goes down for three seconds? Check out MCSignOnDoor, by me! It's not a bukkit plugin, so you won't find it here in BukkitDev! (This ad brought to you by me.)

  • Avatar of judam judam Nov 13, 2013 at 01:49 UTC - 0 likes

    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

    Last edited Nov 13, 2013 by judam

Facts

Date created
Nov 14, 2011
Categories
Last update
Sep 07, 2012
Development stage
Release
Language
  • enUS
License
Creative Commons BY-NC-SA 3.0
Curse link
Commander
Downloads
10,732
Recent files
  • B: v2.0.1 for CB 1.3.1-R2.0 Sep 07, 2012
  • R: v1.2.3 for CB 1.3.1-R2.0 Aug 28, 2012
  • A: v2.0_ALPHA-2 for CB 1.3.1-R2.0 Aug 25, 2012
  • R: v1.2.2 for CB 1.3.1-R2.0 Aug 22, 2012
  • A: v2.0 ALPHA for CB 1.3.1-R2.0 Aug 22, 2012

Authors