Slimefun / Slimefun4

Slimefun 4 - A unique Spigot/Paper plugin that looks and feels like a modpack. We've been giving you backpacks, jetpacks, reactors and much more since 2013.
GNU General Public License v3.0
958 stars 547 forks source link

Move PlayerProfile saving off the main thread #4119

Closed WalshyDev closed 7 months ago

WalshyDev commented 7 months ago

Description

Moves the PlayerProfile saving off the main thread

Proposed changes

Move PlayerProfile off main thread, add debugs and improve tab completion for debug

Moved the PlayerProfile saving off the main thread, we generally load this off-thread but now we also save off-thread. I thought we were already doing this but apparently not, especially with our current YAML stuff this should definitely be done

Also done a small change to ensure that we don't remove the PlayerProfile from memory if the player is still online. I don't think we ever had a reported issue from this but it's kinda weird behaviour

Finally, added some debug logs to the saving logic, this can be enabled with /sf debug slimefun_player_profile_data. Also added auto-complete to /sf debug because it's nice, this only works for Slimefun test cases rather than addons but that's fine. Mostly internal anyway


Please consider any cases where this will cause issues and bring them up!

I think this should be generally safe since we've been saving on-thread but loading off-thread anyway for ages but we should exercise caution. I think with the extra enforcement of the player definitely still being offline there's no issue here but give it a think before approving :)

Related Issues (if applicable)

Resolves #4118

Checklist

github-actions[bot] commented 7 months ago

Your Pull Request was automatically labelled as: "🧹 Chores" Thank you for contributing to this project! ❤️

github-actions[bot] commented 7 months ago

Slimefun preview build

A Slimefun preview build is available for testing! Commit: 5f6706bf

https://preview-builds.walshy.dev/download/Slimefun/4119/5f6706bf

Note: This is not a supported build and is only here for the purposes of testing. Do not run this on a live server and do not report bugs anywhere but this PR!

WalshyDev commented 7 months ago

I tested a basic profile with just researches and with research + backpacks (both Slimefun items and vanilla). Each one could save without issue

sonarcloud[bot] commented 7 months ago

Quality Gate Passed Quality Gate passed

The SonarCloud Quality Gate passed, but some issues were introduced.

9 New issues
0 Security Hotspots
19.2% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud