Overriding vanilla Minecraft commands?

Discussion in 'CommandHelper' started by Murreey, Sep 29, 2017.

  1. Murreey

    Murreey Member

    I've had my own version of Minecraft's /tell implemented through CH for years, but with the 1.12.2 update it stopped working and the vanilla command is taking priority. I'm registering it through a register_command() which used to work fine. I know it's still running and registering because I can use some of the aliases (which aren't in vanilla) to get to it, but the main command and the other aliases all use the vanilla command now.

    Is this something that's changed in the latest CH build, and how would I make the registered command take priority? Thanks.
  2. PseudoKnight

    PseudoKnight Well-Known Member

    It's not clear what version of Bukkit you just updated from. There are a few Bukkit commits that affect this. Like, there's one that fixed an issue in late 1.12 that was introduced in 1.12 Pre2, but that doesn't make sense if you just updated to 1.12.2 from 1.12.1. So I'm guessing it has to do with register order, seeing as you're doing it in an non-guaranteed fashion.

    So, it works like this:

    1. A plugin attempts to register a command that already exists.
    2. If it's an alias or BukkitCommand, it fails.
    3. If the command it's trying to overwrite is not an alias, it fails.
    4. Otherwise command is replaced.

    So first come first served, unless it's an alias.

    I always use CH aliases when overriding instead of registering a command that is already registered. You may be able to unregister a vanilla command, just in case, before registering your command. But it might also be that you're just delaying registration until after vanilla commands are registered.
  3. Murreey

    Murreey Member

    Yeah it was just from 1.12.1 to 1.12.2, and to the latest CH.

    Interestingly it seems it is overriding the original command, but not the aliases for the original command. I'm registering it as `msg`, with aliases `message`, `tell`, `pm`, `w` and `whisper`. Running any of those that are also in vanilla uses the vanilla /tell, except for /tell itself which runs my command.

    I tried adding an unregister /tell before my register is run and it still works the same. The unregister() returns false, which I guess means unsuccessful.