Running Commands Through The Console

Discussion in 'Plugin Development' started by GabeGaming11, Feb 22, 2015.

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

    GabeGaming11

    OK, I am making a plugin in which I need to run a /give command.
    The only problem is, if I give them permission to do /give then they can cheat!

    I have a main class that extends JavaPlugin and a listener class that implements listener. I tried making the listener class also extend JavaPlugin but this didn't work. I need to run a command from the console meaning I need to have the line that will run the command in the main class but my plugin needs to detect for an event to make it happen.

    (Sorry if this is unclear)

    Any help?
    Thanks
     
  2. Online

    timtower Administrator Administrator Moderator

    @GabeGaming11 Are you using a constructor in your listener class to have an instance of the main plugin in there?
     
  3. Offline

    MajorSkillage

    Only 1 class can extend JavaPlugin, this is own as your main class which is set in the plugin.yml. A listener class needs to be registered from the main class. Also if you wish to run commands through console just use this
    Code:
    getServer().dispatchCommand(getConsoleSender(), "command console runs");
     
Thread Status:
Not open for further replies.

Share This Page