Add completion contributor for Bukkit event handlers#2613
Add completion contributor for Bukkit event handlers#2613Leguan16 wants to merge 3 commits intominecraft-dev:devfrom
Conversation
|
That's cool |
Earthcomputer
left a comment
There was a problem hiding this comment.
In addition to my specific comments:
- Please make sure to include license headers in all files.
- The constants (inside the companion objects) should go in
BukkitConstants. I believe some of them may already be there.
|
|
||
| val eventNameFilter = prefix.substring(2).lowercase() | ||
|
|
||
| ClassInheritorsSearch.search(eventBaseClass, scope, true) |
There was a problem hiding this comment.
This looks expensive. However it's not so easy to cache effectively because the easiest way to do that is using the PSI modification count as the cache key, and since you're in a completion provider that is changing on every keystroke. Leave it as it is for now.
| template.isToReformat = true | ||
|
|
||
| template.addTextSegment("@${EVENT_HANDLER_FQN}\n") | ||
| template.addTextSegment("public void ") |
There was a problem hiding this comment.
I see that the format of this template is hard-coded. Some people might want a different format, like have their methods be package-private (like I do). Some people might also want a different default method name (I've seen people put on as every handler's method name), or even different default event name. Perhaps it could be beneficial to expose properly editing the template in some way? IntelliJ already provides an interface for users to edit templates for these things, so perhaps you could hook into that and provide the method names/event params as built-in variables instead?
There was a problem hiding this comment.
I will read into it thanks for making me aware of this.
3d708a9 to
f8e9e4f
Compare
Adds a completion contributor for Bukkit event handlers.
It only works in a class that implements
org.bukkit.event.Listener.It uses templates to generate the method and provide opportunity to change method name and parameter name.
Screen.Recording.2026-04-21.192030.mp4
I initially created this as a poc after someone (Strokkur) posted a video of him doing something similar and wanted to try if i can implement the same logic using the plugin SDK.
If this ends up getting added we can also add Strokkur as co-author for the idea if he wants to, i don't mind that.