CommandAPI icon indicating copy to clipboard operation
CommandAPI copied to clipboard

Command unregisteration does not work

Open soshimee opened this issue 3 years ago • 4 comments

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

soshimee avatar Sep 19 '22 12:09 soshimee

Plugin disabling occurs via ServerUtils.

JorelAli avatar Sep 19 '22 12:09 JorelAli

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.

DerEchtePilz avatar Sep 19 '22 12:09 DerEchtePilz

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.

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)

JorelAli avatar Sep 19 '22 12:09 JorelAli

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.

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)

I tested this with the gamemode command and it got disabled. Seems like you literally cannot disable /reload which is sad.

DerEchtePilz avatar Sep 27 '22 16:09 DerEchtePilz

/help does not want to be unregistered, but for example /kick works

zmatez avatar Nov 29 '22 19:11 zmatez

/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).

JorelAli avatar Nov 30 '22 14:11 JorelAli

@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?

DerEchtePilz avatar Sep 01 '23 21:09 DerEchtePilz

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.

opl- avatar Oct 05 '23 23:10 opl-

@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!

DerEchtePilz avatar Oct 06 '23 19:10 DerEchtePilz