feat: Run post-initialization method at the first server tick #1465
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.
Motivation
Certain features of CloudNet react to services updating and thus changing their state to "Running". In the current implementation, this update happens at the time the bridge module/plugin/extension is enabled. This timing is not ideal as a lot of time-consuming tasks, like generating or loading the worlds/dimensions and other modules/plugins/extensions may happen after that. This causes the other components, like the signs module or the NPCs module, to report those services as being already online and ready to join by players, whilst the opposite is actually the case.
Modification
All currently supported server software platform integrations are augmented, so that
PlatformBridgeManagement#postInit
is called in the first game tick. This tick is only called, once the server is actually initialized, loaded and running. This also means that the server is ready to accept players.Result
Amongst other things, signs now show the server for joining only, once the server is actually ready to accept players.
Testing
This change has been successfully tested with servers running Paper, Fabric and Limbo.