Loading Commands From a Outside Source?

Discussion in 'Plugin Development' started by Orcem12, Jun 6, 2012.

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

    Orcem12

    I may sound crazy... But how does one simply create, register, and use plugins that are say in the directory: "/plugins/<plugin-name>/Commands" I've tried googling. No results.

    If you don't quite understand what I mean let me create a short scenario:
    - I am supa developer and I want my plugin to have commands from an outside source; preferably from a directory inside the plugin's data folder. How would I do this? Using a <command-name>.jar
     
  2. Offline

    Taces

    I think it's not possible to set the command by a config file, because you have to define all your commands in the plugin.yml.
    But i think you could do this in a "passive" way:
    Create a config file with each command you have and write a listener for PlayerCommandPreprocessEvent.
    In the listener get the command and check if it's somewhere set in your config file. If so, just replace the command you received with your actual command.
    For better understanding here an example:
    -You have the command /jump.
    -in your plugin.yml its defined as "jump"
    - in the config file there is a entry named "jump"
    -A user sets "jump" in the config to "fly"
    - In the listener you get the command he sended ("/fly")
    - You check your configs and notice that "jump" has the entry "fly"
    - Simply replace "fly" with "jump" and it's done ;)

    I wrote a plugin for the server im playing on which simplyfies some commands. E.g. the residence commands, beceause they are quite complex. So the users just tape "/grundinfo" and my plugins changes it to "/res current" or summat ;)
     
Thread Status:
Not open for further replies.

Share This Page