Commands only work if they're in the Main class

Discussion in 'Plugin Development' started by largeuntiedknot, Dec 7, 2019.

  1. Offline

    largeuntiedknot

    I'm having an issue where my commands don't work AT ALL, unless they're in Main.java. And even if they're in Main.java, they still don't work!

    upload_2019-12-8_13-54-34.png

    /nameget:
    upload_2019-12-8_13-55-16.png
    nothing

    /die:
    upload_2019-12-8_13-55-23.png
    nothing

    /gmt:
    upload_2019-12-8_13-55-27.png
    nothing
    (yes I used the same screenshots but they are supposed to do something)

    upload_2019-12-8_13-56-27.png
    upload_2019-12-8_13-56-51.png
    upload_2019-12-8_13-57-11.png

    none work
    upload_2019-12-8_13-57-33.png
    they SHOULD work, but since java is like 30000 years old and spigot's code is a burrito from wendy's.
    md_5 pls fix
     
  2. Offline

    timtower Moderator Moderator

    @largeuntiedknoth Should only work if you tell the server that the class is the commandexecutor for that command.
    Did you do that?
     
  3. Offline

    djbomber36

    @largeuntiedknot You have to put this in your onEnable method:

    Code:
    this.getCommand("your command name").setExecutor(new YourCommandClass());
     
  4. Offline

    Strahan

    JavaPlugin already implements CommandExecutor, so no need to implement it again. Also, there is no need to check the name in the classes you setup for each command because once you set the executor for the command to that class, the class's onCommand will only be ran for that command.

    Checking name is only necessary when you have multiple commands going to one class. Also don't forget to specify your commands in the plugin.yml
     

Share This Page