Delegate Bukkit command registering logic to CommandRegistrationStrategy#560
Merged
DerEchtePilz merged 10 commits intodev/devfrom Jun 6, 2024
Merged
Conversation
…tegy` Just a rough example implementation `NMS#getResourceDispatcher` replaced by `NMS#createCommandRegistrationStrategy`, which creates a `SpigotCommandRegistration` implementation using the resources dispatcher Alternate fix for #554. If we're on Paper-1.20.6-65, a `PaperCommandRegistration` implementation is used instead. This can be used to properly handle the internal changes made by PaperMC/Paper#8235.
…cher` It seems the underlying field accessed by running `this.<MinecraftServer>getMinecraftServer().getCommands().getDispatcher()` changes at some point. So, calling this during load actually results in just another copy of the `brigadierDispatcher`. However, if we call it later, it correctly returns the `resourcesDispatcher`.
…mands are unregistered Avoids reintroducing unregistered commands after `/minecraft:reload`
DerEchtePilz
reviewed
Jun 3, 2024
Comment on lines
+25
to
+27
| public PaperCommandRegistration( | ||
| Supplier<CommandDispatcher<Source>> getBrigadierDispatcher, Predicate<CommandNode<Source>> isBukkitCommand | ||
| ) { |
Member
There was a problem hiding this comment.
This is some me kind of nitpick but can we have this on one line?
Collaborator
Author
There was a problem hiding this comment.
Fair enough. I think I expected to need to add more parameters (like SpigotCommandRegistration), but just two is a reasonable length.
Member
We don't care. They don't change the output of the compiled code, the only downside to them is it's harder for humans to statically analyse code by staring at it in something other than an IDE, but it's 2024 and that's basically irrelevant. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR moves a lot of the current logic for registering commands on Bukkit into the class
SpigotCommandRegistration. This allows an alternate implementation of the newCommandRegistrationStrategyinterface to be loaded when internal changes from PaperMC/Paper#8235 (Paper-1.20.6-65 and later) are present. TheCommandRegistrationStrategyis created by the methodNMS#createCommandRegistrationStrategy.This is a more permanent fix than #555 and resolves these issues when running on Paper-1.20.65 and later:
/minecraft:reloaddeletes CommandAPI commands (Thanks FireML on Discord)unregisterBukkitparameter ofCommandAPIBukkit#unregisterisn't fully taken into accountThe implementation can still probably be refined by #517 (e.g. CommandAPI-Spigot should never need
PaperCommandRegistration, and later Paper versions should never needSpigotCommandReigistration)The NMS methods
getResourcesDispatcher,isVanillaCommandWrapper,wrapToVanillaCommandWrapper, andisBukkitCommandWrapperwere moved toSpigotCommandRegistrationbecause they only make sense if Paper changes are not present. These methods are only used in the CommandAPI bySpigotCommandRegistrationanyway, but developers can still access them usingCommandAPIBukkit#getCommandRegistrationStrategy.PaperCommandRegistrationprovides a similar method:isBukkitCommand.TODO:
Before merging I want to double check that the following works
unregisterBukkitparameter is repsectedminecraft:reloadOn the following versions:
Latest Paper (Paper-1.20.6-131)
Paper-1.20.6-65
Paper-1.20.6-64
Paper-1.20.5
Paper-1.20.4
Spigot 1.20.6
Spigot 1.20.4
And of course~ code review is greatly appreciated!