You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With the advent of Paper plugins, calling into the CommandMap for registration is now recommended over the plugin.yml's commands section. The CommandMap#register method exists; however, there is no #unregister method. Yet plugins would benefit from de-registering; for example, if the plugin implements configurable aliases, or if it is a dedicated alias plugin outright.
Describe the solution you'd like.
Add a CommandMap#unregister method to remove a command entirely.
Describe alternatives you've considered.
Continue to instruct developers to mutate the known commands map returned from CommandMap#getKnownCommands. This solution is more error-prone and less discoverable. It is easy to call, for example, commandMap.getKnownCommands().values().remove(myCommand) without realizing the provided command may be registered under multiple aliases.
Also, getKnownCommands() is not documented as mutable. In fact, command unregistration via the CommandMap is not documented at all. The reason for this is that programmatic registration remained a rare use-case hardly possible on older API versions. For example, Server#getCommandMap was added by Paper and didn't exist in Spigot for a while (maybe it still doesn't -- I don't know). Hence, some plugins reflect into SimplePluginManager to get the command map, with an extra reflection step to access the known commands field.
This discussion was converted from issue #9670 on April 28, 2024 17:49.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Is your feature request related to a problem?
With the advent of Paper plugins, calling into the CommandMap for registration is now recommended over the plugin.yml's commands section. The CommandMap#register method exists; however, there is no #unregister method. Yet plugins would benefit from de-registering; for example, if the plugin implements configurable aliases, or if it is a dedicated alias plugin outright.
Describe the solution you'd like.
Add a CommandMap#unregister method to remove a command entirely.
Describe alternatives you've considered.
Continue to instruct developers to mutate the known commands map returned from
CommandMap#getKnownCommands
. This solution is more error-prone and less discoverable. It is easy to call, for example,commandMap.getKnownCommands().values().remove(myCommand)
without realizing the provided command may be registered under multiple aliases.Also,
getKnownCommands()
is not documented as mutable. In fact, command unregistration via the CommandMap is not documented at all. The reason for this is that programmatic registration remained a rare use-case hardly possible on older API versions. For example, Server#getCommandMap was added by Paper and didn't exist in Spigot for a while (maybe it still doesn't -- I don't know). Hence, some plugins reflect into SimplePluginManager to get the command map, with an extra reflection step to access the known commands field.Other
No response
Beta Was this translation helpful? Give feedback.
All reactions