Solved Getting and Registering Commands with the Bukkit CommandMap

Discussion in 'Spigot Plugin Development' started by DarkPaladinUHC, Apr 28, 2017.

  1. I have been trying to register my commands with the Bukkit CommandMap for a while now but I just can't seen to get it working. I am using Spigot 1.8.8

    Here is how I am trying to get the command Map
    Code (Text):
    try {
                final Field f = Bukkit.getServer().getClass().getDeclaredField("commandMap");
                commandMap = (CommandMap) f.get(Bukkit.getServer());
            } catch (Exception e) {
    and that hasn't thrown any errors

    and then to register commands I am doing
    Code (Text):
    PluginCommand pCmd = core.getCommand(cmd.getName());

            if (pCmd == null)

            pCmd.setUsage("/" + cmd.getName() + " " + cmd.getUsage());

            Core.getCommandMap().register(Core.instance.getDescription().getName(), pCmd);

    Still no errors there.

    Anyway, if anyone can see what the problem here is that would be great!
    #1 DarkPaladinUHC, Apr 28, 2017
    Last edited: Apr 28, 2017
  2. I am not seeing where you are registering commands through the CommandMap. Can you point it out please?
    • Like Like x 1
  3. Okay thanks. I have been able to register command through the CommandMap. One more thing, do you know how you can increase the priority of the commands. For instance If I made a gamemode command but vanilla minecraft also has a gamemode command mine will override minecraft's. Thanks so much!
    #5 DarkPaladinUHC, Apr 30, 2017
    Last edited: Apr 30, 2017
  4. Yep no problem! And I think it just overrides it automatically if you have a command like that. :p
  5. It doesn't override automatically