iconomy5legacy / iConomy

iConomy 5 (Towny Edition)
15 stars 14 forks source link

Asynchronous Towny Tax collection only counts the last modification to town balance #17

Closed Hugo5000 closed 3 years ago

Hugo5000 commented 3 years ago

The problem is that the add or subtract method of the Holder class could are run asynchronously in the same tick, resulting in the following:

balance = 100

add(10); => balance is 100, adding 10, new balance is 110, schedule BalanceUpdateEvent for next tick; add(20); => balance is still 100 since its still the same tick, adding 20, new balance is 120, schedule BalanceUpdateEvent for next tick;

-- next tick --

setting balance to 110 setting balance to 120 => first add is ignored"

related pull request: #16 If there is a better solution to this, please do implement that, this was the fastest and easiest way I could think of how to fix it.

Hugo5000 commented 3 years ago

I have made an alternative pull request #18 that addresses this issue by making the events able to run in an async thread instead of synchronising them to the main thread.