iconomy5legacy / iConomy

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

Running the Holdings.add and Holdings.subtract method synchronously #16

Closed Hugo5000 closed 3 years ago

Hugo5000 commented 3 years ago

Running the add and subtract method synchronously to prevent the overriding of balances, for example:

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"

Hugo5000 commented 3 years ago

I still have one concern with this pull request, that the logging shows the old balance since that isn't inside the sync task.

LlmDl commented 3 years ago

I'm looking at the logging side of things and it would appear that it is being done via this sort of code: iConomy.getTransactions().insert("[Vault]", playerName, 0.0D, balance, 0.0D, amount, 0.0D); This should probably get moved downstream into the Holdings class.

LlmDl commented 3 years ago

I'm looking at the logging side of things and it would appear that it is being done via this sort of code: iConomy.getTransactions().insert("[Vault]", playerName, 0.0D, balance, 0.0D, amount, 0.0D); This should probably get moved downstream into the Holdings class.

I've looked this over and I don't think it will be manageable. The logging is already fairly spotty and I don't really care if its sacrificed over fixing this issue.

The account update events are cancel-able in the end and the log doesn't take that into account either.