btk5h / skript-db

MIT License
5 stars 5 forks source link

[Bug] Failed to read BlockState due to asynchronous access #17

Open antoinech2 opened 5 years ago

antoinech2 commented 5 years ago

Hello again, I've found an other bug with skript-db

When I right click on a enchantment table, this error pop in the console. I know skript-bd has nothing to do with the enchantments tables, but when I remove the plugin the error disappears. I noticed there is a link to the fact that the thread is asynchronous (I think) (Tell me if you want the error in a pastebin or something like that)

[11:16:00] [pool-40-thread-8/WARN]: java.util.concurrent.CompletionException: java.lang.RuntimeException: Failed to read BlockState at: world: world location: (579, 63, -149) [11:16:00] [pool-40-thread-8/WARN]: at java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:273) [11:16:00] [pool-40-thread-8/WARN]: at java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:280) [11:16:00] [pool-40-thread-8/WARN]: at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1592) [11:16:00] [pool-40-thread-8/WARN]: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [11:16:00] [pool-40-thread-8/WARN]: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [11:16:00] [pool-40-thread-8/WARN]: at java.lang.Thread.run(Thread.java:748) [11:16:00] [pool-40-thread-8/WARN]: Caused by: java.lang.RuntimeException: Failed to read BlockState at: world: world location: (579, 63, -149) [11:16:00] [pool-40-thread-8/WARN]: at org.bukkit.craftbukkit.v1_14_R1.block.CraftBlockEntityState.<init>(CraftBlockEntityState.java:49) [11:16:00] [pool-40-thread-8/WARN]: at org.bukkit.craftbukkit.v1_14_R1.block.CraftEnchantingTable.<init>(CraftEnchantingTable.java:12) [11:16:00] [pool-40-thread-8/WARN]: at org.bukkit.craftbukkit.v1_14_R1.block.CraftBlock.getState0(CraftBlock.java:437) [11:16:00] [pool-40-thread-8/WARN]: at org.bukkit.craftbukkit.v1_14_R1.block.CraftBlock.getState(CraftBlock.java:322) [11:16:00] [pool-40-thread-8/WARN]: at org.bukkit.craftbukkit.v1_14_R1.block.CraftBlock.getState(CraftBlock.java:316) [11:16:00] [pool-40-thread-8/WARN]: at ch.njol.skript.aliases.ItemType.<init>(ItemType.java:222) [11:16:00] [pool-40-thread-8/WARN]: at ch.njol.skript.aliases.ItemType.toString(ItemType.java:1008) [11:16:00] [pool-40-thread-8/WARN]: at ch.njol.skript.classes.data.BukkitClasses$2.toString(BukkitClasses.java:193) [11:16:00] [pool-40-thread-8/WARN]: at ch.njol.skript.classes.data.BukkitClasses$2.toString(BukkitClasses.java:1) [11:16:00] [pool-40-thread-8/WARN]: at ch.njol.skript.registrations.Classes.toString(Classes.java:601) [11:16:00] [pool-40-thread-8/WARN]: at ch.njol.skript.registrations.Classes.toString(Classes.java:630) [11:16:00] [pool-40-thread-8/WARN]: at ch.njol.skript.registrations.Classes.toString(Classes.java:615) [11:16:00] [pool-40-thread-8/WARN]: at ch.njol.skript.lang.VariableString.toString(VariableString.java:459) [11:16:00] [pool-40-thread-8/WARN]: at ch.njol.skript.lang.VariableString.getArray(VariableString.java:623) [11:16:00] [pool-40-thread-8/WARN]: at ch.njol.skript.lang.VariableString.getArray(VariableString.java:1) [11:16:00] [pool-40-thread-8/WARN]: at com.btk5h.skriptdb.skript.ExprUnsafe.get(ExprUnsafe.java:37) [11:16:00] [pool-40-thread-8/WARN]: at com.btk5h.skriptdb.skript.ExprUnsafe.get(ExprUnsafe.java:22) [11:16:00] [pool-40-thread-8/WARN]: at ch.njol.skript.lang.util.SimpleExpression.getArray(SimpleExpression.java:102) [11:16:00] [pool-40-thread-8/WARN]: at ch.njol.skript.lang.util.SimpleExpression.getSingle(SimpleExpression.java:60) [11:16:00] [pool-40-thread-8/WARN]: at com.btk5h.skriptdb.skript.EffExecuteStatement.createStatement(EffExecuteStatement.java:155) [11:16:00] [pool-40-thread-8/WARN]: at com.btk5h.skriptdb.skript.EffExecuteStatement.executeStatement(EffExecuteStatement.java:122) [11:16:00] [pool-40-thread-8/WARN]: at com.btk5h.skriptdb.skript.EffExecuteStatement.lambda$execute$0(EffExecuteStatement.java:94) [11:16:00] [pool-40-thread-8/WARN]: at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1590) [11:16:00] [pool-40-thread-8/WARN]: ... 3 more [11:16:00] [pool-40-thread-8/WARN]: Caused by: java.lang.IllegalStateException: Tile is null, asynchronous access? CraftBlock{pos=BlockPosition{x=579, y=63, z=-149},type=ENCHANTING_TABLE,data=Block{minecraft:enchanting_table},fluid=net.minecraft.server.v1_14_R1.FluidTypeEmpty@cd1e646} [11:16:00] [pool-40-thread-8/WARN]: at com.google.common.base.Preconditions.checkState(Preconditions.java:444) [11:16:00] [pool-40-thread-8/WARN]: at org.bukkit.craftbukkit.v1_14_R1.block.CraftBlockEntityState.<init>(CraftBlockEntityState.java:30) [11:16:00] [pool-40-thread-8/WARN]: ... 25 more

btk5h commented 5 years ago

Code?

antoinech2 commented 5 years ago

No code...

I will check by disabling my skripts

antoinech2 commented 5 years ago

I found the script that makes the error: The code is: on right click on a chest, furnace, shulker box, dropper, dispenser, hopper, trapped chest, anvil or enchantment table: execute unsafe "INSERT INTO skript_coffrelog (datetime,joueur,action,block,x_coord,y_coord,z_coord,world) VALUES (NOW(),'%player%','OPEN','%targeted block of player%',%round up x coord of targeted block of player%,%round up y coord of targeted block of player%,%round up z coord of targeted block of player%,'%world of player%')" in {mysql_db}

antoinech2 commented 5 years ago

Additional informations:

antoinech2 commented 5 years ago

Okay, I've test more things, and I noticed that skript-bd don't replace local variables with their values! It works for global variables Exemple:

set {_test} to "test1" set {test} to "test2" execute unsafe "INSERT INTO skript_test (test1,test2) VALUES ('%{_test}%','%{test}%')" in {mysql_db}

the 'test1' value is < none > is the SQL table, but the 'test2' value is correct ("test2")

btk5h commented 5 years ago

I know what's causing the problem, though it might be a while until I have the time to fix it.

The local variable problem is an issue with Skript itself.