randombyte-developer / lottery

A Sponge plugin
https://ore.spongepowered.org/RandomByte/Lottery
GNU General Public License v2.0
0 stars 1 forks source link

Wrong messages order #2

Closed aso824 closed 7 years ago

aso824 commented 7 years ago

From console:

[19:41:42] [pool-2-thread-4274/INFO]: XYZ won the lottery pot of 135.0$! [19:41:42] [pool-2-thread-4247/INFO]: Current pot is at 135.0$! Use /lottery buy [amount] to buy tickets!

Second message should not appear at all, or should show 0.0$. Please note that same order see all clients, this isn't bug only in console.

randombyte-developer commented 7 years ago

Interesting, thanks for reporting this! What's your broadcast interval and draw interval in the config? Does this always happen on an automatic draw? Can it be triggered by manually drawing (with the command)? It seems that the drawing and broadcasting happen at the same time because the both are asynchronous tasks. It's a rare coincidence I think.

aso824 commented 7 years ago

Broadcast interval - 30 minutes, draw interval - 6 hours. It's caused only in automatic draw. I assume that both tasks start on server start? Then it's no wonder that it happens :D And probably when I use manual draw, bug won't show up before next server restart.

randombyte-developer commented 7 years ago

The tasks have a set interval which will be only recalculated when the plugin reloads(by command or server restart). They are not reset at manual draw. So this won't work. A temporary workaround is setting one of the intervals to like 3 seconds longer. I'd suggest changing the draw interval because it is bigger and therefore it needs more time to match up with the broadcast interval. With your intervals there will be one case in 7200 interval cycles that would give a bad result if my calculations are correct.

Of course I'll fix this bug(sooner or later), but I have to see how I'm going to do it.