EverNife / FinalEconomy

1 stars 1 forks source link

EconomyUpdateEvent cannot be triggered asynchronously from another thread #2

Closed HatTrkPatrk closed 1 year ago

HatTrkPatrk commented 1 year ago

[20Jan2023 14:06:24.090] [pool-11-thread-1/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1050]: java.lang.IllegalStateException: EconomyUpdateEvent cannot be triggered asynchronously from another thread. [20Jan2023 14:06:24.091] [pool-11-thread-1/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1050]: at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:572) [20Jan2023 14:06:24.091] [pool-11-thread-1/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1050]: at br.com.finalcraft.finaleconomy.config.data.FEPlayerData.setRecentChanged(FEPlayerData.java:51) [20Jan2023 14:06:24.091] [pool-11-thread-1/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1050]: at br.com.finalcraft.finaleconomy.config.data.FEPlayerData.removeMoney(FEPlayerData.java:40) [20Jan2023 14:06:24.091] [pool-11-thread-1/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1050]: at br.com.finalcraft.finaleconomy.vault.VaultEconomy.withdrawPlayer(VaultEconomy.java:60) [20Jan2023 14:06:24.091] [pool-11-thread-1/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1050]: at br.com.finalcraft.finaleconomy.vault.FinalEcoAbstract.withdrawPlayer(FinalEcoAbstract.java:85) [20Jan2023 14:06:24.091] [pool-11-thread-1/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1050]: at com.griefdefender.util.EconomyUtil.withdrawFunds(EconomyUtil.java:145) [20Jan2023 14:06:24.091] [pool-11-thread-1/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1050]: at com.griefdefender.claim.GDClaim.resize(GDClaim.java:1578) [20Jan2023 14:06:24.091] [pool-11-thread-1/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1050]: at com.griefdefender.listener.PlayerEventHandler.handleResizeFinish(PlayerEventHandler.java:1889) [20Jan2023 14:06:24.092] [pool-11-thread-1/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1050]: at com.griefdefender.listener.PlayerEventHandler.onPlayerHandleClaimCreateAction(PlayerEventHandler.java:1419) [20Jan2023 14:06:24.092] [pool-11-thread-1/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1050]: at com.griefdefender.listener.PlayerEventHandler.lambda$onPlayerInteractItem$1(PlayerEventHandler.java:662) [20Jan2023 14:06:24.092] [pool-11-thread-1/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1050]: at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [20Jan2023 14:06:24.092] [pool-11-thread-1/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1050]: at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [20Jan2023 14:06:24.092] [pool-11-thread-1/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1050]: at java.base/java.lang.Thread.run(Thread.java:829) [20Jan2023 14:06:28.409] [pool-11-thread-2/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1050]: java.lang.IllegalStateException: EconomyUpdateEvent cannot be triggered asynchronously from another thread. [20Jan2023 14:06:28.409] [pool-11-thread-2/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1050]: at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:572) [20Jan2023 14:06:28.409] [pool-11-thread-2/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1050]: at br.com.finalcraft.finaleconomy.config.data.FEPlayerData.setRecentChanged(FEPlayerData.java:51) [20Jan2023 14:06:28.409] [pool-11-thread-2/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1050]: at br.com.finalcraft.finaleconomy.config.data.FEPlayerData.removeMoney(FEPlayerData.java:40) [20Jan2023 14:06:28.409] [pool-11-thread-2/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1050]: at br.com.finalcraft.finaleconomy.vault.VaultEconomy.withdrawPlayer(VaultEconomy.java:60) [20Jan2023 14:06:28.410] [pool-11-thread-2/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1050]: at br.com.finalcraft.finaleconomy.vault.FinalEcoAbstract.withdrawPlayer(FinalEcoAbstract.java:85) [20Jan2023 14:06:28.410] [pool-11-thread-2/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1050]: at com.griefdefender.util.EconomyUtil.withdrawFunds(EconomyUtil.java:145) [20Jan2023 14:06:28.410] [pool-11-thread-2/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1050]: at com.griefdefender.claim.GDClaim.resize(GDClaim.java:1578) [20Jan2023 14:06:28.410] [pool-11-thread-2/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1050]: at com.griefdefender.listener.PlayerEventHandler.handleResizeFinish(PlayerEventHandler.java:1889) [20Jan2023 14:06:28.410] [pool-11-thread-2/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1050]: at com.griefdefender.listener.PlayerEventHandler.onPlayerHandleClaimCreateAction(PlayerEventHandler.java:1419) [20Jan2023 14:06:28.410] [pool-11-thread-2/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1050]: at com.griefdefender.listener.PlayerEventHandler.lambda$onPlayerInteractItem$1(PlayerEventHandler.java:662) [20Jan2023 14:06:28.410] [pool-11-thread-2/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1050]: at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [20Jan2023 14:06:28.410] [pool-11-thread-2/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1050]: at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [20Jan2023 14:06:28.410] [pool-11-thread-2/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1050]: at java.base/java.lang.Thread.run(Thread.java:829)

In terms of a specific case that caused it, I'm using GriefDefender with FinalEconomy and the error occurs when trying to resize a claim with the golden shovel.

EverNife commented 1 year ago

The error is not on my end.

Since Spigot 1.13 i think: "events should respect their syncronization state!"

So the econmy manipulation should be done syncronized witht he main Thread.

Anyway. I will create a workaround for these plugins that does not respect it.

HatTrkPatrk commented 1 year ago

The Grief Defender devs told me the error is caused by the economy plugin so I posted here. I will return to them with this then, thank you.

Also thank you for creating a workaround either way!

EverNife commented 1 year ago

The error is caused because of a change on the Spigot Api!

The class: SimplePluginManager.callEvent()

On Minecraft 1.12.2 and prior this method did not check if the event passed was on the right thread.

So, an event that said "I am syncronized with the main Thread" could be called from outside the main thread.

Since 1.13*(i think is 1.13) there is a check on it, and these events are now required to be called on the correct Thread!

FinalEconomy fire an EconomyUpdateEvent, and it is suposed to be always on the main thread! And in 1.12.2 and prior there was no problem when external plugins did something wrong, because Bukkit would not care about that.

But now they do care!


Also, over several issues under the VaultAPI they state vault is not ThreadSafe.

Take a look here: https://github.com/MilkBowl/Vault/issues/514

For the economy plugin to ""Enforce a ThreadSafe"" is just a waste of processing.

EverNife commented 1 year ago

I will make a release with the fix soon