1.14.4 My minecraft server doens't see my class

Discussion in 'Spigot Plugin Development' started by NMZCyt, Feb 11, 2020.

Thread Status:
Not open for further replies.
  1. in metod onEnable you forgot to prescribe it, so I edited it for you.
    Code (Text):
        public void onEnable() {
            Bukkit.getPluginManager().registerEvents(this, this);
            getCommand("hallo").setExecutor(this);
        }
    Should make money
     
    #2 Ansl, Feb 11, 2020
    Last edited: Feb 11, 2020
  2. MiniDigger

    Supporter

    Might also add that he should add the @Override annotation to avoid issues like that...
     
    • Agree Agree x 1
  3. make @Override onEnable and onDisable and register all classes and Commands!
     
  4. forgot=)
     
  5. drives_a_ford

    Moderator

    JavaPlugin already implements [/url]https://hub.spigotmc.org/javadocs/spigot/org/bukkit/command/TabExecutor.html]TabExecutor[/url], which extends CommandExecutor. So no need to declare it.
    And more importantly, the command's owning plugin is already the default executor of the PluginCommand.


    But that's not really your issue. Your issue is the fact that the .jar you've provided has the plugin.yml and doesn't have the class files. How are you compiling your jar exactly? You could try and navigate in the jar (it's an archive file) to see if any of your classes exist.

    EDIT:
    Why are you suggesting they register the plugin as a listener? It doesn't even implement the Listener interface.
     
    • Agree Agree x 1
  6. do you mean that i need a @Override annotation over the OnEnable and over the OnDisable
     
  7. Thank you Snx and ansl it worked and i used your answers
     
    • Like Like x 1
  8. Strahan

    Benefactor

    Also there is no need to check if the command is hallo if hallo is the only command in use.
     
  9. but i'm gonna add more commands
     
  10. No Problem! :)
     
  11. Please mark this thread as solved, so others don't think you're still needing help.
     
  12. Strahan

    Benefactor

    Lemme just highlight part of what I said for you ;)

    If you are going to register more, than obv this doesn't apply which is why I added that conditional. I'm not in your head, so I don't know what you plan for your plugin.
     
  13. It's a good idea to register your commands somewhere outside of your main class. Make the new command class implement CommandExecutor, then use this in your onEnable() method:

    getCommand("your command name").setExecutor(new YourCommandClass());
     
  14. its very easy and good for a sorted code! :)
     
    • Like Like x 1
  15. it won't see them
     

    Attached Files:

  16. You need to provide a (possibly empty) parameter list for your constructor invocation.
     
  17. wdym?
     
  18. All class constructor invocations need a argument list provided to them, in the same way method calls do. In your case, you omitted them, so it doesn't understand what you want to do. You need to specify the arguments if your constructor has any and if not provide an empty argument list with only the parentheses.
     
  19. .setExecutor(new HelloCommand()); since, as Stef said, you would be invoking the constructor of that class
     
    • Informative Informative x 1
Thread Status:
Not open for further replies.