CmdControl ⚙ Link Commands | Create Aliases | Add Cooldowns/Costs | & More!

CmdControl :gear:

CmdControl - Developed by Simon_Flash ([email protected])
Current Version: 1.1.0-pr1
Current Stable Version: 1.0.1
Status: Active → New features and updates are in development

GitHub | Download | Wiki | Support Discord

Note: CmdControl is built on API 6 (1.11.2), but is also confirmed working for API 5 (1.10.2). API 7 has not been tested.


Overview :trophy:

CmdControl provides additional options for working with commands, primarily through it’s scripting functionality. Scripts can allow you to:

  • Combine multiple commands into a single command
  • Create multiple aliases for commands
  • Accept arguments for commands
  • Add cooldowns to commands
  • Add costs to commands

Additionally, it is intended to have various utility commands for common actions (such as delaying commands, requiring a player to be online, etc.) in the future.

Why CmdControl? :books:

CmdControl has a very readable, user friendly configuration system that does not require any form of coding experience to use. Errors are printed out both to the console, as well as place directly above the configuration node that caused the issue.

Additionally, CmdControl verifies the type of arguments before any commands are actually executed, which many other alias/scripting plugins do not. This prevents a situation where a portion of commands execute properly while others fail, which can lead to issues like players receiving only half of a kit. With CmdControl, this problem virtually disappears!

Getting Started :pick:

Learning CmdControl is going to take a bit of trial and error, but I’ve done the best I can do document it’s main functionality with a bunch of examples on the wiki (linked above). Additionally, you’ll be able reference some default scripts when the plugin is first installed to help you get set up. I’m working on getting a stronger tutorial up for CmdControl, so keep an eye out for that!

After creating your first script, you’re going to need to address permissions. Each script has it’s set of permissions, which match the following:

  • cmdcontrol.scripts.<script-name>.base: Base permission to run this script
  • cmdcontrol.scripts.<script-name>.nocooldown: Bypasses the cooldown (if set)
  • cmdcontrol.scripts.<script-name>.nocost: Bypasses the cost (if set)

All scripts may able be run using /executescript or /script, like below. This permission is separate from individual script permissions.

  • /script <script-name> [args...]: Executes <script-name> with the given args...

Questions & Issues :interrobang:

If you need support for any aspect of CmdControl and you have already checked the wiki page, simply ask below or join the support discord above and ask in #cmdcontrol. Please include any information relevant to your problem such as the Sponge version, the CmdControl version, the script’s config file, and so on. I’ll do my best to respond to any of this quickly, but please be considerate and know that these things aren’t instantaneous.

Suggestions & Feedback :mega:

If you have a suggestion for CmdControl or would just like to provide some feedback, feel free to get in contact with me in any of the ways above. I’d love to see what kind of creative thing you can figure out with scripts - one of my first was a google bot script, so see if you can beat that!

Fun Statistics :bar_chart:

  • This plugin has been in development since March
  • It was created because I hated Skript
  • It’s name has been changed 4 times
  • The first working form confused basically everyone
  • It was used to fix the /back -f issue in Nucleus
  • The current form was programmed in 4 days
  • It is the only know plugin like it to type-verify arguments
5 Likes

When you write “/command” on the wiki, the items below indicate what the command does when run, right?

/command is a placeholder for either /script <script-name> or one of the scripts aliases. The lines after that describe some aspect of what happens in the script, but not necessarily the direct output of the command.

1 Like

So, for example, I start out with the example:

` arguments=[
{
name=“player”
type=“Player”
},{
name=“message”
type=“JoinedStrings”
}
]
/command Simon_Flash CmdControl is awesome!

  • Argument 1: Simon_Flash
  • Argument 2: CmdControl is awesome! `

How do I specify the name of the command, is it just via typing /script <script-name>? And is all this located and scripted in the config file?

I’ll start configuring it in-game and on the config tomorrow when I have the time, currently just browsing around the wiki and getting a taste of the plugin. :slight_smile:

The name of the script is directly dependent on the name of the file, so lighten.script has the name of lighten. The script name is used in permissions as well as the /script <script-name> command, which will run any script.

If the script has any aliases defined, those may be used like normal commands.

//in the file lighten.script (so the script name is lighten)

arguments=[...]
executors=[...]
metadata {
    aliases=[
        "example"
    ]
}

The following commands all have the same effect.

/executescript lighten [args...] //CmdControl's script command
/script lighten [args...] //Also CmdControl's script command
/example [args...] //An alias defined by the metadata of the script

//Where [args...] is whatever arguments as defined by the script

Everything in CmdControl is handled through the config file for the script. Hopefully this clarifies a few things!

Additionally, the easiest way to work with this type of stuff is really just to try it out. For the same reason, you can’t learn how to code without actually coding. Practice makes perfect ^^

Cool plugin! Since you know which type is expected as an argument, how about tab completing some of them(e.g. Players, choices, tristate, boolean …).

1 Like

Nice plugin Simon!

I was wondering if you were going to expose an API for this, because then i could integrate it into my Web-API plugin to allow users to create/modify scripts through a web interface.

2 Likes

Oh, so there’s a file for every command? I get it now! :slight_smile:
Thanks!

Okay, last question:
So let’s say I want to make a command that is named let’s say /kitpvp with no arguments or anything else, and it runs the commands:
/give Differentiation diamond_sword
/effect Differentiation health_boost 10000 4 true

How would I incorporate the commands to make one whole command?
Sorry I’m asking too many questions, it’s just that I want to get the hang of the plugin, then be able to go on from there!
Thank you! :slight_smile:

@RandomByte
Thank you! Running tab completion isn’t a possibility (for now!) because a script isn’t actually a command - I just listen in to any command sent and see if it matches one of the aliases. This would actually end up being a bit of a side effect of creating a CommandSpec for the script and ‘officially’ registering the new command with Sponge. I’m half hoping that dualspiral’s command PR is accepted before I get to that, but I have a feeling I haven’t seen the last of GenericArguments.

@Valandur
Thanks for the kind words! Somewhat adding to the note above, the only idea I have planned for an API is a system to register a custom argument type with it’s own system of verification and so on. I haven’t considered any type of API to create scripts, but if you’d like to send me a message I’m more that willing to talk with you about it!

@Differentiation
Each command acts as a separate executor; so for two commands there would be two different executors in the list. One thing I have not mentioned (thanks for the indirect reminder!) is the use of <@Sender> to retrieve whatever processed the script. Additionally, I purposefully use the term executor so it isn’t confused with the commands inside, and it has more than just a command anyways. In total, that would look something like this:

executors=[
    { //First executor, first command
        command="give <@Sender> diamond_sword"
        source="Server" //presuming you want the server 
    },{ //Second executor, second command
        command="effect <@Sender> health_boost 10000 4 true"
        source="Server"
    }
]
metadata {
    aliases=[
        "kitpvp" //Defines the /kitpvp alias
    ]
}

No worries about having too many questions; it actually helps me a lot for pinpointing what people are having trouble with and finding good ways to explain these concepts. Don’t forget there’s a support discord for some of the more particular things too. Good luck!

So if I want to target all the players, what would replace <@Sender>?

For all online players the vanilla selector @a.

1 Like

Using @a as RandomByte said is the best option for now because if the command supports @a, it should be perfectly safe to use. Unfortunately, there’s a lot of command that aren’t safe to use (teleport, for example) as well as any command who’s permission is not given to the default group, among other fringe scenarios.

At the same time, it doesn’t mean it’s impossible, and there’s already plans in the works for a system that would have this be a byproduct - I’ll leave you to guess what it’s real purpose is. :wink:

Hey,Simon_Flash,you really did a great job!
May I promote your plugin and translate from English into Chinese?

Sure. I can’t afford the time to provide continued support for that at the moment, but I do plan on getting a language file set up Soon™.

Greeting all! This update is a quick patch for a bug with blank arguments, but it also contains the start of an API to allow plugins to define custom ValueTypes - not to mention a step towards using a proper command registration system. If you’re not a developer, might be best to skip to the changelog below.

In order for CmdControl to verify the type of an argument, I used an enum of possible types where a constant could override a getParsedType method to retrieve the proper object, as seen in the ArgType class. This is rather messy to begin with and it doesn’t support any type of system to register custom types through an API.

Instead, I decided on using an abstract class named ValueType with an associated TypeRegistry. This allows a custom type to define it’s own CommandElement to handle the process of parsing arguments. The type also defines it’s own name, various parameters, and what it’s value should look like as a String. There are a few issues with it that I’m working on resolving, but I think it’s progressing nicely and is easy to understand and implement.

As this is my first attempt at any sort of external API, I’d be grateful for any feedback on the system above as well as any suggestions you other developers might have. Thanks!


Have you forgotten there was a release by now?

Changelog:

  • Started ValueType Registry API
  • Fixed an issue with blank arguments
  • Small code cleanup/rearrangements

Issues should be reported with the version [1.0.1]

can this be used to run the command as if the player had permissions? for example i want to add different cooldowns for my donor ranks for the command breed from pixelmon extras sidemod, as of now the current command has 1 cooldown for everyone, but i would like to make different cooldowns for different ranks, is it possible to add an alias for example /breed1 and it will execute the /breed command without the players needing that permission node?

Notice: This update is a pre-release, meaning that bugs, issues, and breaking changes from the previous version are to be expected. Use at your own discretion!


Another week another update! This time I think I outdid myself, so let’s get right to it!

This update has some of the most difficult code that I’ve ever written to this point - not only was it logically complicated, but it also includes my first attempt at an API for any of my plugins. Best of all, CmdControl now uses the full power of Sponge’s Command API: Specs and Elements and Executors, oh my! This means that you should experience less errors (eventually!), more detailed messages, tab completion, and all the other benefits that come with it. We’re not quite at the point of registering child commands, but we’re super close!

Among other things, I will note that the system used to handle meta information in both Arguments and Executors has changed, and is now more dependent on the type itself. I’ll get these things document when I can!

Lastly, if you a developer who is willing to consider having their plugin support CmdControl, please look into how to register a custom ValueType here, and please toss me any feedback!

Oh, and while writing this I realized that I forgot to register any aliases - hey, it is a pre-release! For now, you’ll have to use /script <script-name> <arguments>, but I’ll be sure to get on top of that ASAP!


Changelog:

  • Implemented used of the CommandAPI
  • Added ValueType, default ValueTypes, and ValueTypeEntry
  • Added TypeRegistry API
  • Redesigned the config and storage systems
  • Simplified script processing
  • Rewrote script classes with internal checks
  • Removed error-comments config node
  • Changed ‘type-meta’ and ‘source-meta’ nodes to ‘meta’

Issues should be reported with the version [v1.1.0-pr1]


@RandomByte Interestingly enough, tab complete was one of the many positive side effects from converting to the Command API. Well, would you look at that! :wink:

@Valandur The API in question for this update isn’t related to building or editing scripts, but I kept this in mind and built all of the necessary requirements and checks into their constructors. It’ll be a while before I rewrite that to support making edits, but for now that should be sufficient - send me a message if you need help or there’s something else I can clarify!

@_InfinityMC I generally only make update related notes here, but I’d rather not double post. I had a conversation with @Luck a couple months ago regarding this issue in API 5. This may have changed since then, but I do not recall any patch notes regarding this and it wasn’t in the API 7 Permissions PR. You could give the player the permission at the start of the script and remove it at the end, but that can have unwanted side effects.

Alternative, it’s rather trivial to use CmdControl’s cooldown system by declaring a cooldown value in the script’s metadata. The main disadvantage to this would be requiring a separate command for each script, but I’m hoping I’ll be able to find a solution to that by getting creative with CommandElements.

1 Like

I’m sorry to see that you hated Skript. I loved Skript and miss it dearly. Anyway, does your plugin have the same ability as Skript in regards to creating custom commands? I saw that you mentioned this plugin grants the ability to add arguments and such to existing commands, but I didn’t see anything about being able to make a brand new command. Also, would it be possible to have conditions to be met for the events executed in the command? A more specific example, I want to make a command that has a 3% chance of triggering what the command triggers. FInally, would it also be possible for variables to be used?

I want to make a command that has a 3% chance of triggering the /pokespawncoords command, adding in variables to randomly select which Pokemon is spawned. Since you said you hated Skript, you must be familiar with the format even if a little. Such a command in Skript would be written as follows:

command /randpokespawn:
trigger:
chance of 3%:
set {randPoke} to a random integer between 1 and 2
if {randPoke} is 1:
set {pokeSpawned} to Rattata
else if {randPoke} is 2:
set {pokeSpawned} to Pidgey
execute console command “pokespawncoords %{pokeSpawned}% %player%”

Sorry for throwing Skript format at you, but I wanted to show what it was I am trying to do. Thanks for the help!