NPE on withdraw from vault and enderchest
Got NPE while trying withdraw money from vault.
Precondition:
- Vault chest has 1002
- Inventory 0
- Enderchest has 20 I`m using last 2.12.5 version
Steps to reproduce: type /money withdraw 1022
Expected: 1022 will be transfered to inventory.
Actual: All money in vault (1002) disappeared. Nothing comes to inventory.
[09:29:32 INFO]: MorjTop1GG issued server command: /balance withdraw 1022
[09:29:32 ERROR]: null
org.bukkit.command.CommandException: Unhandled exception executing command 'balance' in plugin Gringotts v2.12.5
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:47) ~[purpur-api-1.20.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:168) ~[purpur-api-1.20.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_20_R1.CraftServer.dispatchCommand(CraftServer.java:947) ~[purpur-1.20.1.jar:git-Purpur-1996]
at org.bukkit.craftbukkit.v1_20_R1.command.BukkitCommandWrapper.run(BukkitCommandWrapper.java:64) ~[purpur-1.20.1.jar:git-Purpur-1996]
at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:265) ~[purpur-1.20.1.jar:?]
at net.minecraft.commands.Commands.performCommand(Commands.java:332) ~[?:?]
at net.minecraft.commands.Commands.performCommand(Commands.java:316) ~[?:?]
at net.minecraft.server.network.ServerGamePacketListenerImpl.performChatCommand(ServerGamePacketListenerImpl.java:2391) ~[?:?]
at net.minecraft.server.network.ServerGamePacketListenerImpl.lambda$handleChatCommand$21(ServerGamePacketListenerImpl.java:2351) ~[?:?]
at net.minecraft.util.thread.BlockableEventLoop.lambda$submitAsync$0(BlockableEventLoop.java:59) ~[?:?]
at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768) ~[?:?]
at net.minecraft.server.TickTask.run(TickTask.java:18) ~[purpur-1.20.1.jar:git-Purpur-1996]
at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:153) ~[?:?]
at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:24) ~[?:?]
at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:1366) ~[purpur-1.20.1.jar:git-Purpur-1996]
at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:197) ~[purpur-1.20.1.jar:git-Purpur-1996]
at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:126) ~[?:?]
at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:1343) ~[purpur-1.20.1.jar:git-Purpur-1996]
at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:1336) ~[purpur-1.20.1.jar:git-Purpur-1996]
at net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:136) ~[?:?]
at net.minecraft.server.MinecraftServer.waitUntilNextTick(MinecraftServer.java:1314) ~[purpur-1.20.1.jar:git-Purpur-1996]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1202) ~[purpur-1.20.1.jar:git-Purpur-1996]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:323) ~[purpur-1.20.1.jar:git-Purpur-1996]
at java.lang.Thread.run(Thread.java:1583) ~[?:?]
Caused by: org.gestern.gringotts.GringottsException: java.util.concurrent.ExecutionException: java.lang.NullPointerException: Cannot invoke "org.bukkit.inventory.ItemStack.getType()" because "itemStack" is null
at org.gestern.gringotts.GringottsAccount.getTimeout(GringottsAccount.java:470) ~[gringotts-2.12.5.jar:?]
at org.gestern.gringotts.GringottsAccount.remove(GringottsAccount.java:304) ~[gringotts-2.12.5.jar:?]
at org.gestern.gringotts.api.impl.GringottsEco$ValidPlayerAccount.withdraw(GringottsEco.java:785) ~[gringotts-2.12.5.jar:?]
at org.gestern.gringotts.commands.GringottsAbstractExecutor.withdraw(GringottsAbstractExecutor.java:158) ~[gringotts-2.12.5.jar:?]
at org.gestern.gringotts.commands.MoneyExecutor.onCommand(MoneyExecutor.java:59) ~[gringotts-2.12.5.jar:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[purpur-api-1.20.1-R0.1-SNAPSHOT.jar:?]
... 23 more
Caused by: java.util.concurrent.ExecutionException: java.lang.NullPointerException: Cannot invoke "org.bukkit.inventory.ItemStack.getType()" because "itemStack" is null
at java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:396) ~[?:?]
at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2096) ~[?:?]
at org.gestern.gringotts.GringottsAccount.getTimeout(GringottsAccount.java:468) ~[gringotts-2.12.5.jar:?]
at org.gestern.gringotts.GringottsAccount.remove(GringottsAccount.java:304) ~[gringotts-2.12.5.jar:?]
at org.gestern.gringotts.api.impl.GringottsEco$ValidPlayerAccount.withdraw(GringottsEco.java:785) ~[gringotts-2.12.5.jar:?]
at org.gestern.gringotts.commands.GringottsAbstractExecutor.withdraw(GringottsAbstractExecutor.java:158) ~[gringotts-2.12.5.jar:?]
at org.gestern.gringotts.commands.MoneyExecutor.onCommand(MoneyExecutor.java:59) ~[gringotts-2.12.5.jar:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[purpur-api-1.20.1-R0.1-SNAPSHOT.jar:?]
... 23 more
Caused by: java.lang.NullPointerException: Cannot invoke "org.bukkit.inventory.ItemStack.getType()" because "itemStack" is null
at org.gestern.gringotts.GringottsAccount.removeFromShulkerBox(GringottsAccount.java:332) ~[gringotts-2.12.5.jar:?]
at org.gestern.gringotts.GringottsAccount.lambda$remove$2(GringottsAccount.java:265) ~[gringotts-2.12.5.jar:?]
at org.gestern.gringotts.GringottsAccount.lambda$callSync$0(GringottsAccount.java:54) ~[gringotts-2.12.5.jar:?]
at org.gestern.gringotts.GringottsAccount.callSync(GringottsAccount.java:61) ~[gringotts-2.12.5.jar:?]
at org.gestern.gringotts.GringottsAccount.remove(GringottsAccount.java:304) ~[gringotts-2.12.5.jar:?]
at org.gestern.gringotts.api.impl.GringottsEco$ValidPlayerAccount.withdraw(GringottsEco.java:785) ~[gringotts-2.12.5.jar:?]
at org.gestern.gringotts.commands.GringottsAbstractExecutor.withdraw(GringottsAbstractExecutor.java:158) ~[gringotts-2.12.5.jar:?]
at org.gestern.gringotts.commands.MoneyExecutor.onCommand(MoneyExecutor.java:59) ~[gringotts-2.12.5.jar:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[purpur-api-1.20.1-R0.1-SNAPSHOT.jar:?]
... 23 more
@nikosgram Can it be the place where null check is missed? I see fix on add method, but there is no check on remove...
This also happens when you have multiple vault chests and the withdrawal exceeds the amount that is in the first chest.
Steps to reproduce (using 2.12.5 version on paper-1.20.4-365): First Vault Chest : put in (or use /m deposit) 1000 currency equivalent in items Second Vault Chest : put in (or use /m deposit) 1000 currency equivalent in items /m withdraw 1001 (any amount exceeding the contents on the first chest
Expected Result: 1001 will be transferred to inventory.
Actual Result: All items in the First Vault Chest have disappeared. Nothing has changed in the Second Vault Chest. Nothing comes to inventory.
I wanted try and dig into the code and try and fix this myself, but I need some Maven training. I can't even get it to compile. :(
This also happens when you have multiple vault chests and the withdrawal exceeds the amount that is in the first chest.
Steps to reproduce (using 2.12.5 version on paper-1.20.4-365): First Vault Chest : put in (or use /m deposit) 1000 currency equivalent in items Second Vault Chest : put in (or use /m deposit) 1000 currency equivalent in items /m withdraw 1001 (any amount exceeding the contents on the first chest
Expected Result: 1001 will be transferred to inventory.
Actual Result: All items in the First Vault Chest have disappeared. Nothing has changed in the Second Vault Chest. Nothing comes to inventory.
I wanted try and dig into the code and try and fix this myself, but I need some Maven training. I can't even get it to compile. :(
As for me it was helpful just to restrict enderchest use as vault, together with restriction for users to create own vaults. All vaults was created by responsible person on player request in the bank. It helps to avoid this double vault problem.
BTW I didn't have any problems with the build... but I couldn't fix it too) need to debug and lookup deeper into logic
This also happens when you have multiple vault chests and the withdrawal exceeds the amount that is in the first chest. Steps to reproduce (using 2.12.5 version on paper-1.20.4-365): First Vault Chest : put in (or use /m deposit) 1000 currency equivalent in items Second Vault Chest : put in (or use /m deposit) 1000 currency equivalent in items /m withdraw 1001 (any amount exceeding the contents on the first chest Expected Result: 1001 will be transferred to inventory. Actual Result: All items in the First Vault Chest have disappeared. Nothing has changed in the Second Vault Chest. Nothing comes to inventory. I wanted try and dig into the code and try and fix this myself, but I need some Maven training. I can't even get it to compile. :(
As for me it was helpful just to restrict enderchest use as vault, together with restriction for users to create own vaults. All vaults was created by responsible person on player request in the bank. It helps to avoid this double vault problem.
BTW I didn't have any problems with the build... but I couldn't fix it too) need to debug and lookup deeper into logic
I'm sure the build is fine... I just don't know how to do it. :)
Please try this test build https://github.com/weaves7/Gringotts/releases/tag/v.2.12.7-SNAPSHOT