Allow platform-specific configuration, Add hook-paper-reload config option#388
Merged
JorelAli merged 12 commits intoCommandAPI:dev/devfrom Dec 30, 2022
Merged
Allow platform-specific configuration, Add hook-paper-reload config option#388JorelAli merged 12 commits intoCommandAPI:dev/devfrom
JorelAli merged 12 commits intoCommandAPI:dev/devfrom
Conversation
Make CommandAPIConfig a ChainableBuilder
copied from CommandAPI@2d8ac6c
JorelAli
requested changes
Dec 30, 2022
Member
JorelAli
left a comment
There was a problem hiding this comment.
I've pointed out a few minor changes to do with wording of some end-user-facing documentation and an assertion that I'd like added to check if users try to use the paper-specific configuration option on a non-paper server.
I've not done any manual testing, but just by static analysis of the current implementation, everything looks fairly clean and robust. I'm not going to let manual testing prevent this PR from merging, but it's something I'd like to do before 9.0.0's release.
...bukkit/commandapi-bukkit-core/src/main/java/dev/jorel/commandapi/CommandAPIBukkitConfig.java
Show resolved
Hide resolved
commandapi-platforms/commandapi-bukkit/commandapi-bukkit-plugin/src/main/resources/config.yml
Outdated
Show resolved
Hide resolved
commandapi-platforms/commandapi-bukkit/commandapi-bukkit-plugin/src/main/resources/config.yml
Outdated
Show resolved
Hide resolved
JorelAli
approved these changes
Dec 30, 2022
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.
The inspiration for this PR started in discord (see here).
This PR does two things:
...which is necessary for...
First,
CommandAPIConfigis now abstract and implementsChainableBuilder. Each platform should have a subclass ofCommandAPIConfig, for example,CommandAPIBukkitConfig. Any information needed for configuring the platform specifically can be added to the platform implementation, such asshouldHookPaperReload.When a platform is loaded, it will now be passed the config object, which is packaged into an appropriate subclass of
InternalConfig, which can be accessed later.Moving to the second point, when registering the event handler on the
ServerResourcesReloadedEvent, the Bukkit-specific,hook-paper-reloadconfig option is now considered.IMPORTANT:
CommandAPI#onLoadandCommandAPI#onEnablemethod usage has changedPreviously,
CommandAPI#onEnablereceived anObjectthat represented the 'plugin' responsible for loading it. This was done in an attempt to be as backward-compatible as possible.CommandAPI#onEnableused to takeJavaPlugin, but that class is not accessible in a platform-free context, soObjectwas the best bet for that to work.Now, however, the JavaPlugin variable was moved to the
CommandAPIBukkitConfig. It was put in the constructor to make it required to create a Bukkit config object, reflecting how it is required for the CommandAPI to work.Altogether, here's how shaders need to change their code (taken from maven-shaded example)
From:
To:
Planned TODO before merge: