-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disallow calling JavaPlugin#getCommand during onEnable for Paper plugins #11914
base: main
Are you sure you want to change the base?
Conversation
Every other day someone in #paper-dev tries to declare commands in paper-plugin.yml, which is not supported, but simply returns null instead of a clear error message. This commit hopes to clarify that calling getCommand on self is not supported for paper plugins. Note: check only applies during onEnable because we do not want to break the ability for other plugins to check if a plugin defines a command by calling JavaPlugin#getCommand on it
related to #10588 |
You are trying to call JavaPlugin#getCommand on a Paper plugin during startup: | ||
you are probably trying to get a command you tried to define in paper-plugin.yml. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these first lines really needed? I feel like the last two are enough or am I wrong?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to be extra clear, since the majority of people asking about this in paper-dev seem to be new to plugin development (or development in general), so I wanted to make sure they go to exactly the right place.
That being said, the stacktrace will also show the right location, so maybe it's indeed too verbose?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But the 2 lines basically say the same.
Maybe something like this?
Paper plugins do not support YAML-based command declarations!
You are probably trying to get a command via JavaPlugin#getCommand that you defined in paper-plugin.yml.
This method of command declaration is not supported when using Paper plugins.
Please check the documentation for more information on how to define commands in Paper plugins: https://docs.papermc.io/paper/dev/getting-started/paper-plugins#commands
Also do you guys rename Paper plugins to Lifecycle plugins? Maybe reflect that already?
RE:
That being said, the stacktrace will also show the right location, so maybe it's indeed too verbose?
Without wanting to make assumptions i think that "new to plugin development (or development in general)" wont know how to read a stacktrace. So we should not consider that as a factor here. As you said you want to be extra clear and I think being a bit more verboste makes sense.
Every other day someone in #paper-dev tries to declare commands in paper-plugin.yml and use JavaPlugin#getCommand, which is not supported, but simply returns null instead of a clear error message.
This commit hopes to clarify that calling getCommand on self is not supported for paper plugins.
Note: check only applies during onEnable because we do not want to break the ability for other plugins to check if a plugin defines a command by calling JavaPlugin#getCommand on it