Implement reload manager API and add Fabric/NeoForge hooks#11
Merged
Conversation
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 pull request introduces a cross-platform "reload runnable" API to MatthiesenLib, allowing mods to register callbacks that will be executed when a server reload occurs (e.g., data pack reload). The implementation covers both Fabric and NeoForge, ensuring that registered reload actions are executed with logging and error handling. The API exposes new methods for registering and retrieving reload callbacks, and the library's main facade forwards these for convenience.
New Reload Runnable API:
MatthiesenLibReloadManagerto manage per-mod reload callbacks, including methods to register and retrieve runnables, with duplicate registration checks and logging ([api/common/src/main/java/dev/matthiesen/common/matthiesen_lib_api/core/MatthiesenLibReloadManager.javaR1-R56](https://github.com/Matthiesen-dev/matthiesen-lib/pull/11/files#diff-f39cbb951f4a0d486353f7530d5ab6fe9f4d824833569cba3cf92e60bb790b78R1-R56)).registerReloadRunnableandgetReloadRunnablesmethods on bothMatthiesenLibApiand the main facadeMatthiesenLibfor mod developer use ([[1]](https://github.com/Matthiesen-dev/matthiesen-lib/pull/11/files#diff-5f4886732ac5f6667652572a901adf1f3b79d41a243d3df8531f0cb3d6548520R186-R204),[[2]](https://github.com/Matthiesen-dev/matthiesen-lib/pull/11/files#diff-0220b44d25d092beeb57278778807d974425641a5b1f1373e119ccfa830b2eddR224-R242)).Platform Integration for Reload Events:
ServerLifecycleEvents.END_DATA_PACK_RELOADto execute all registered reload runnables on successful reload, with per-mod logging and error handling ([api/fabric/src/main/java/dev/matthiesen/fabric/matthiesen_lib_api/MatthiesenLibApiFabric.javaR32-R46](https://github.com/Matthiesen-dev/matthiesen-lib/pull/11/files#diff-fe97a1bcca8f2fc461a4d2ae2edf4c9578bc81acbd5da06737735003b1a25d41R32-R46)).AddReloadListenerEventand adds a helperMatthiesenLibReloadListenerthat runs all registered reload callbacks with logging and error handling during the reload phase ([[1]](https://github.com/Matthiesen-dev/matthiesen-lib/pull/11/files#diff-32fcbe55464e3aa03de84f2a1ff09e6ff515a42817d6679653b0cabb9169dd36R46-R54),[[2]](https://github.com/Matthiesen-dev/matthiesen-lib/pull/11/files#diff-359a3cd498773127ea682a540c18adf6ab3cd47261e192342c7dee227dad851bR1-R37)).Documentation:
DEV-DOCS.mdwith migration notes, usage instructions, and behavioral details for the new reload API, including platform-specific integration notes ([DEV-DOCS.mdR5-R32](https://github.com/Matthiesen-dev/matthiesen-lib/pull/11/files#diff-a99cd6dc6474e1605545d40164dac228efd82dc274af2f9b593922135bda1651R5-R32)).