Command unregisteration does not work
CommandAPI version
8.5.1
Minecraft version
1.19.2
Are you shading the CommandAPI?
No
What I did
- https://commandapi.jorel.dev/8.5.1/reloading.html
What actually happened
The command never unregisters when disabling the plugin using reload or another plugin.
What should have happened
It should unregister properly and disappear.
Server logs and CommandAPI config
No response
Other
No response
Plugin disabling occurs via ServerUtils.
As far as I am aware, disabling should also work with vanilla commands, right?
For example, if I have something like this: CommandAPI.unregister("reload");, it should unload all reload-commands.
Because if it does, this has nothing to do with ServerUtils, but is a CommandAPI issue.
As far as I am aware, disabling should also work with vanilla commands, right? For example, if I have something like this:
CommandAPI.unregister("reload");, it should unload allreload-commands. Because if it does, this has nothing to do with ServerUtils, but is a CommandAPI issue.
Yes, this should work for (almost) any vanilla command. There are a few vanilla commands that are exempt from this (not sure about /reload, but I think /help is exempt).
The reason I mentioned ServerUtils is because ServerUtils has the functionality to disable a plugin, whereas calling /reload disables a plugin (and presumably unregisters it) and then enables the plugin (which would re-register it)
As far as I am aware, disabling should also work with vanilla commands, right? For example, if I have something like this:
CommandAPI.unregister("reload");, it should unload allreload-commands. Because if it does, this has nothing to do with ServerUtils, but is a CommandAPI issue.Yes, this should work for (almost) any vanilla command. There are a few vanilla commands that are exempt from this (not sure about /reload, but I think /help is exempt).
The reason I mentioned ServerUtils is because ServerUtils has the functionality to disable a plugin, whereas calling
/reloaddisables a plugin (and presumably unregisters it) and then enables the plugin (which would re-register it)
I tested this with the gamemode command and it got disabled. Seems like you literally cannot disable /reload which is sad.
/help does not want to be unregistered, but for example /kick works
/help does not want to be unregistered, but for example /kick works
If I recall, there are a few commands which are "immune" to being unregistered, as stated here:
Yes, this should work for (almost) any vanilla command. There are a few vanilla commands that are exempt from this (not sure about /reload, but I think /help is exempt).
@soshimee Recently, CommandAPI v9.1.0 was released. In this version, changes to the command unregistration system were made. If you use 9.1.0, does this issue still persist?
I had a conversation about what could be the same issue on Discord today (link). In my case it was caused by not calling onEnable when shading CommandAPI v9.2.0 in my plugin (docs here, running git-Paper-524 (MC: 1.19.4) (Git: 9846d0d)).
Using exactly the same code but running CommandAPI v9.0.3 instead of v9.2.0 makes it fail to unregister the command again.
@soshimee Just tested your setup with CommandAPI 9.2.0, Minecraft 1.20.1, and used ServerUtils to disable the test plugin. I used this code to register the command:
new CommandAPICommand("ping")
.executes((sender, args) -> {
sender.sendMessage("Pong!");
})
.register();
I used this code to unregister the command:
CommandAPI.unregister("ping");
After running /serverutils disableplugin BugTestingCommandAPI, the ping command did no longer exist.
Closing this for now, if any further issues appear, please reply to this!