Solved Command aliases not working?

Discussion in 'Spigot Plugin Development' started by DrOreo002, Aug 9, 2018.

  1. I don't know why, but the command aliases that I used on the plugin.yml is not working...

    Here's my command class

    Here's my plugin.yml
    Code (Text):
    name: OreoHome
    version: 1.0
    main: me.droreo002.oreohome.OreoHome
    depend: [Essentials, Vault, Pagination]

        aliases: [tampar]
        aliases: [ahome, ahm]
        aliases: [rumah, hm, h]
    And yes, the command is registered and the /home command is working fine, but when I ran the "h" command it does nothing, it goes same as the other too

    Edit :

    For those who have this problem. Its more likely because of essentials get loaded first before your plugin. (Only if you depend on it), so to fix this. You'll need to unregister the command using the code below (look at the second page). And then you'll need to register it back using this

    You'll also need to change your command class to extend BukkitCommand. Btw only use this if you need to, I don't really recommended you to change the way you register command.
    #1 DrOreo002, Aug 9, 2018
    Last edited: Aug 10, 2018
  2. And in the plugin class, you set an instance of MainCommand as executor, right? Like so:
    Code (Text):
    @Override public void onEnable() {
      getCommand("home").setExecutor(new MainCommand(this));
  3. Yes
  4. Is there any errors in the console?
  5. There's no error on the console apparently
  6. Is it just /h that isn't working or is it all the aliases?
  7. I'm stumped. You could check if the server knows about the aliases like so:
    Code (Text):
    System.out.println(("Aliases: " + Bukkit.getServer().getPluginCommand("home").getAliases()));
    Although I really don't see why it wouldn't because your plugin.yml looks correct. It would be neat to know to narrow down where the error is exactly.
  8. I'm thinking it could be another plugin uses /h that is installed
  9. Every aliases on the "home" command.
  10. It could be, but every aliases on the home command is also not working somehow
  11. Tried it, there's an aliases for that command (ehome, from essentials). But there's no aliases that is on my plugin.yml :/, weird. Essentials suppose to disable their command completely if there's other command on the server right?
  12. That can be changed in their config, but by default they should disable theirs I think.

    Does /<your plugin name>:home work?
  13. I have no idea what Essentials does. Come to think of it, you should be able to access all your commands and aliases with a prefix.
    Code (Text):
    Does that yield any success? Also, what did it say when you tried the getAliases() thing above?
  14. I've tried to disable the home command on the essentials's config. But its not working :/, idk why
  15. That do nothing apparently
  16. It seems like the essentials command is disabled automatically. I've tried to use the aliases (ehome) from essentials and it run my command instead. But my custom aliases from my plugin.yml is not working. It prob because essentials override it :/
  17. Then the problem is your code doesn't work?
  18. My code works. When I do /home it works, but when I do /h or /hm it does nothing
  19. Are you sure you are running your code and not essentials?
    Code (Java):
    player.sendMessage("debug message");
    to your command and see if you get the message.
  20. I'm 100% sure it run my command, not essentials