Hello, I have identified issue with respawn timers and updated deprecated Bucket AsyncDelayedTasks.
The issue with timers
Current State
When a chest is scheduled to respawn in Utils.copychest method, exact time to respawn X is calculated (in seconds). Then a task is scheduled to run in exactly X * 20 ticks and it runs lc.spawn(false);.
One of the checks that function does is running Lootchest.checkIfTimeToRespawn method. However this check calculates time to respawn again, this time let's call it Y.
The issue is that X ends up being a tiny bit smaller than Y, so the checkIfTimeToRespawn will fail most of the times.
I don't exactly know what the issue is, but I suspect that it might have something to do with server ticks and the task being scheduled too early. There might possibly even be a rounding error as respawn timers are set in seconds but are calculated later with a bigger precision - milliseconds.
My fix
I have added 5 additional seconds to X, so that the scheduled task with lc.spawn(false) runs a bit later. This results in Lootchest.checkIfTimeToRespawn never failing and chests keep respawning.
Honestly, I don't think my fix of adding 5 seconds is good enough to be a proper fix. My intention is to explain the issue, so that someone more experienced with plugin development can fix it properly, without having to spend too much time identifying it.
Hello, I have identified issue with respawn timers and updated deprecated Bucket AsyncDelayedTasks.
The issue with timers
Current State
When a chest is scheduled to respawn in
Utils.copychest
method, exact time to respawn X is calculated (in seconds). Then a task is scheduled to run in exactly X * 20 ticks and it runslc.spawn(false);
. One of the checks that function does is runningLootchest.checkIfTimeToRespawn
method. However this check calculates time to respawn again, this time let's call it Y. The issue is that X ends up being a tiny bit smaller than Y, so the checkIfTimeToRespawn will fail most of the times. I don't exactly know what the issue is, but I suspect that it might have something to do with server ticks and the task being scheduled too early. There might possibly even be a rounding error as respawn timers are set in seconds but are calculated later with a bigger precision - milliseconds.My fix
I have added 5 additional seconds to X, so that the scheduled task with
lc.spawn(false)
runs a bit later. This results inLootchest.checkIfTimeToRespawn
never failing and chests keep respawning.Honestly, I don't think my fix of adding 5 seconds is good enough to be a proper fix. My intention is to explain the issue, so that someone more experienced with plugin development can fix it properly, without having to spend too much time identifying it.