Skip to content
This repository has been archived by the owner on Aug 16, 2024. It is now read-only.

Threaded Weather/Time Updates #24

Open
austinpilz opened this issue Apr 5, 2024 · 1 comment
Open

Threaded Weather/Time Updates #24

austinpilz opened this issue Apr 5, 2024 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@austinpilz
Copy link

Today, the plugin uses the Bukkit scheduler to update the world weather and time using external API calls. This works well when the weather API returns in a timely manner. I've seen a few issues lately across my network where the API calls take a while, and the whole server lags. It took a while to track down, but some thread dumps did the trick.

However, when there's a network interruption, outage, or lag with the HTTP response times, your main thread of the server is left hanging for up to 15 seconds.

The call to the weather API should be done on another thread. Bukkit/Spigot/Paper don't permit you to update in-game attributes (like world or player data) off the main thread. However, this shouldn't be a problem.

  • You can have the craft scheduler periodically run and refresh the data from the API on another thread. It can update plugin-managed variable/map of the weather/time.
  • You have another scheduled task that reads the updated world data from your plugin-managed data structure, and it uses that (on the main thread) to update the world.

With this solution, you'll never have your main thread hanging around waiting for the API call to return.

@NONPLAYT NONPLAYT added enhancement New feature or request good first issue Good for newcomers labels Apr 20, 2024
@NONPLAYT
Copy link
Member

Hello, thank you for suggestion. I'll look into this soon

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants