Define commands in config file possible?

Discussion in 'Plugin Development' started by Williamsson, Aug 11, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    Williamsson

    Hi!

    I want, no, I need, to make commands configurable to my plugin, is this possible?

    Right now I have this:
    Code:
    if (commandLabel.equalsIgnoreCase("racepick") || commandLabel.equalsIgnoreCase("rp")) {
    But I want to fetch the "racepick" or "rp" from a config file, so that it could be "yaddayadda" instead if the serveradmin so desires.


    Rest of the plugin: (just the basics though)
    https://github.com/Williamsson/GroupPick
     
  2. Offline

    Darkman2412

    I think it's not possible because you need to declare all commands of the plugin in your plugin.yml file.
     
  3. Offline

    Williamsson

  4. Offline

    Darkman2412

    Oh well, I took a look into this again, and I think you should use the PlayerCommandPreprocess event.
    I'll give an example:
    This needs to be in your playerListener.
    Code:java
    1. Configuration config = new Configuration();
    2. public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
    3. if(event.getMessage()==config.getString("command", "racepick")) {
    4. //Do stuff
    5. }
    6. }
    7.  


    Oh, and you should read the Apidocs, really helped my alot when I programmed my first plugin! :)
     
Thread Status:
Not open for further replies.

Share This Page