Synchronization Events Pre-Sync and on Dedicated Server #414
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.
New Synchronization Event
This pull request adds a new event,
OnSyncingConfiguration
, that triggers just before applying the synchronized values (on both client and server). This event has it's own class for event args which is currently empty but I thought it was best to keep the same design pattern as theOnConfigurationSynchronized
event and prevent changes in API if other devs want to add argument to the event.Modified
OnConfigurationSynchronized
to Fire on ServerThe event
OnConfigurationSynchronized
has been altered to fire on both the client and the dedicated server after the configuration has been synchronized. I testing the effects of doing this using a mod list that had two different mods that used Jotunn to sync configurations and one that used Blaxxun's ServerSync.I set up the two Jotunn dependant mods to save their configuration files whenever the
OnConfigurationSynchronized
event fired and set up the file-watcher in each mod to reload the configuration file when it was saved so the mod could be updated. when Both of the Jotunn dependent mods used a file-watcher that would reload the configuration file when it was changed and an in-game configuration manager watcher that would save the configuration file when the in-game manager was closed.I tested changing the configuration via the in-game manager, by editing the server configuration file, and editing the local client configuration file. For all test cases the behaviour on the client-side was identical to when
OnConfigurationSynchronized
only fired on the client. For the server, configuration changes were saved just like they were on client whenever "OnConfigurationSynchronized" fired on the server. As far as I can tell from those tests firing the "OnConfigurationSynchronized" even on the server does not result in any sort of infinite synchronization loop or duplicate synchronizations for existing mods.Added Synced PluginGUIDs argument to
OnConfigurationSynchronized
EventThe
OnConfigurationSynchronized
has a new argument that is a HashSet containing the PluginGUID for each plugin that received configuration data from the SynchronizationManager. This is so that plugins can check if they actually had their configuration updated by checking if the HashSet contains their plugin's GUID. This also required caching the PluginGUID for each custom configuration file that is registered so that changes to custom configuration files are tracked appropriately.