Tonnanto / BasicQuests

A plugin for Spigot servers that implements randomly generated basic quests with rewards for players.
GNU General Public License v3.0
11 stars 4 forks source link

performance issues #27

Open matipoirierg opened 3 months ago

matipoirierg commented 3 months ago

https://spark.lucko.me/MoRmNCYAIZ The plugin is spiking my mspt very high, is the chunk loading request async?

Tonnanto commented 3 months ago

It's not. Thanks for pointing out this issue. FindStructureQuests periodically check if a player has found the structure by calling World.locateNearestStructure. I assumed that locating structures within a radius of 3 chunks wouldn't cause any performance issues. However, I just found this in the spigot documentation:

Do not assume that only a radius x radius chunk area will be checked. For example, Structure.MANSION can potentially check up to 20,000 blocks away (or more) regardless of the radius used.

I tried to make the task asynchronous using Bukkit.getScheduler().runTaskAsynchronously. However, this results in the following Error: java.lang.IllegalStateException: StructuresLocateEvent may only be triggered synchronously. Seems like I cannot locate structures asynchronously? Will dig deeper into this when I have the time. I do not have a lot of experience with asynchronous tasks in bukkit development. Any ideas and suggestions are very welcome.

Can you tell me more about: