WiIIiam278 / HuskSync

A modern, cross-server player data synchronisation system
https://william278.net/project/husksync
Apache License 2.0
151 stars 122 forks source link

Add execution-order required/optional dependencies for data types #307

Closed ch4ika closed 1 month ago

ch4ika commented 1 month ago

I've noticed that Health Syncing often can't set the lives correctly because the lives are set first, followed by the attributes. If the attributes are set first and then the health, it works correctly.

grafik

I only did a little debugging and didn't really get an overview.

This issue primarily concerns items that provide extra hearts. If the order of setting attributes and health is reversed, it works fine.

This problem is specifically related to health. If health syncing is enabled but the attributes are not loaded beforehand, the extra health is set to player.getMaxHealth instead of generic_max_health from the attributes.

WiIIiam278 commented 1 month ago

I see, yeah - in essence this is down to the fact that sync data types can't currently depend on others. Not a major issue as in practice max health is usually kept relatively consistent between servers, but can become an issue.

Basically what needs to happen is that sync data types need a way of defining optional/required "dependencies" on other sync data types (by ID), and then for the plugin to correctly go through them in a suitable order. in this case we'd want to make attribute syncing depend on Health/Hunger & Potion Effect syncing first to prevent this sort of issue.

WiIIiam278 commented 1 month ago

@ch4ika If you're able to compile the PR branch #309 and give it ago (in a test environment!), that'd be great. Otherwise, open a ticket on Discord / verify purchase, and I'll send you a build to try.