Siguza / VirtualPack

Bukkit Plugin "VirtualPack"
http://dev.bukkit.org/bukkit-plugins/virtualpack/
7 stars 10 forks source link

Players kicked when shift clicking into virtual containers. #15

Closed mibby closed 10 years ago

mibby commented 10 years ago

@Siguza

Players are kicked from the server when they shift click an item into a virtual container. Anvil, uncrafter, trash bin, etc. They can manually drag the item into the slots, but shift clicking kicks them from the server with the following error output in console.

[18:36:46] [Server thread/WARN]: Failed to handle packet for /IP:PORT
java.lang.NullPointerException
    at net.minecraft.server.v1_7_R3.Container.a(Container.java:529) ~[spigot.jar:git-Spigot-1447]
    at net.minecraft.server.v1_7_R3.ContainerChest.b(ContainerChest.java:82) ~[spigot.jar:git-Spigot-1447]
    at net.minecraft.server.v1_7_R3.Container.clickItem(Container.java:248) ~[spigot.jar:git-Spigot-1447]
    at net.drgnome.virtualpack.components.VContainer.clickItem(VContainer.java:27) ~[?:?]
    at net.minecraft.server.v1_7_R3.PlayerConnection.a(PlayerConnection.java:1408) ~[spigot.jar:git-Spigot-1447]
    at net.minecraft.server.v1_7_R3.PacketPlayInWindowClick.a(SourceFile:32) ~[spigot.jar:git-Spigot-1447]
    at net.minecraft.server.v1_7_R3.PacketPlayInWindowClick.handle(SourceFile:10) ~[spigot.jar:git-Spigot-1447]
    at net.minecraft.server.v1_7_R3.NetworkManager.a(NetworkManager.java:176) ~[spigot.jar:git-Spigot-1447]
    at net.minecraft.server.v1_7_R3.ServerConnection.c(ServerConnection.java:77) [spigot.jar:git-Spigot-1447]
    at net.minecraft.server.v1_7_R3.MinecraftServer.v(MinecraftServer.java:713) [spigot.jar:git-Spigot-1447]
    at net.minecraft.server.v1_7_R3.DedicatedServer.v(DedicatedServer.java:283) [spigot.jar:git-Spigot-1447]
    at net.minecraft.server.v1_7_R3.MinecraftServer.u(MinecraftServer.java:576) [spigot.jar:git-Spigot-1447]
    at net.minecraft.server.v1_7_R3.MinecraftServer.run(MinecraftServer.java:482) [spigot.jar:git-Spigot-1447]
    at net.minecraft.server.v1_7_R3.ThreadServerApplication.run(SourceFile:628) [spigot.jar:git-Spigot-1447]

VirtualChest dev build 100. Minecraft 1.7.9 (latest bukkit upstream)

mibby commented 10 years ago

With uncrafter, same error. Disconnects player with internal server error.

[23:19:44] [Server thread/WARN]: Failed to handle packet for /IP:PORT
java.lang.NullPointerException
    at net.minecraft.server.v1_7_R3.Container.a(Container.java:529) ~[spigot.jar:git-Spigot-1449]
    at net.minecraft.server.v1_7_R3.ContainerChest.b(ContainerChest.java:82) ~[spigot.jar:git-Spigot-1449]
    at net.minecraft.server.v1_7_R3.Container.clickItem(Container.java:248) ~[spigot.jar:git-Spigot-1449]
    at net.drgnome.virtualpack.components.VContainer.clickItem(VContainer.java:27) ~[?:?]
    at net.minecraft.server.v1_7_R3.PlayerConnection.a(PlayerConnection.java:1408) ~[spigot.jar:git-Spigot-1449]
    at net.minecraft.server.v1_7_R3.PacketPlayInWindowClick.a(SourceFile:32) ~[spigot.jar:git-Spigot-1449]
    at net.minecraft.server.v1_7_R3.PacketPlayInWindowClick.handle(SourceFile:10) ~[spigot.jar:git-Spigot-1449]
    at net.minecraft.server.v1_7_R3.NetworkManager.a(NetworkManager.java:176) ~[spigot.jar:git-Spigot-1449]
    at net.minecraft.server.v1_7_R3.ServerConnection.c(ServerConnection.java:77) [spigot.jar:git-Spigot-1449]
    at net.minecraft.server.v1_7_R3.MinecraftServer.v(MinecraftServer.java:713) [spigot.jar:git-Spigot-1449]
    at net.minecraft.server.v1_7_R3.DedicatedServer.v(DedicatedServer.java:283) [spigot.jar:git-Spigot-1449]
    at net.minecraft.server.v1_7_R3.MinecraftServer.u(MinecraftServer.java:576) [spigot.jar:git-Spigot-1449]
    at net.minecraft.server.v1_7_R3.MinecraftServer.run(MinecraftServer.java:482) [spigot.jar:git-Spigot-1449]
    at net.minecraft.server.v1_7_R3.ThreadServerApplication.run(SourceFile:628) [spigot.jar:git-Spigot-1449]
[23:19:44] [Server thread/INFO]: mibby lost connection: Internal server error
Siguza commented 10 years ago

This is spigot's fault and does not happen with CraftBukkit.

Looking at line Container.java, line 529 in Spigot where the error happens:

ItemStack itemstack1 = slot.getItem();
if (itemstack1 == null)
{
    slot.set(itemstack.cloneItemStack());
    slot.f();
    itemstack.count -= slot.getItem().count; // If itemstack1 == null, then slot.getItem() == null. Always.

Looking at the same passage in CraftBukkit:

ItemStack itemstack1 = slot.getItem();
if (itemstack1 == null)
{
    slot.set(itemstack.cloneItemStack());
    slot.f();
    itemstack.count = 0; // No object, no NullPointerException

You should tell md_5 if this isn't fixed the the newer spigot builds already.

mibby commented 10 years ago

Still occurs with latest spigot build, 1449. I reported it to spigot's IRC first and was informed by multiple people it was a plugin error. :/

@md-5 Thoughts?

mibby commented 10 years ago

@thinkofdeath

Thinkofname commented 10 years ago

https://github.com/SpigotMC/Spigot-Server/blob/master/src/main/java/net/minecraft/server/Container.java#L529

https://github.com/Bukkit/CraftBukkit/blob/master/src/main/java/net/minecraft/server/Container.java#L529

Spigot doesn't even touch the file

mibby commented 10 years ago

@Siguza ?

Siguza commented 10 years ago

Ah derp, I was looking at an old CB version, sorry. -.- Gonna debug.

Siguza commented 10 years ago

Ok, I finally found it. Dev build 101 fixes the Uncrafter, Trash and Materializer. I wasn't able to produce the bug on anything else, does it really occur with the Anvil (and others)?

And sorry everyone for the trouble. :/

mibby commented 10 years ago

I had someone report they were kicked when shift clicking an item in the virtual anvil. I'll update and test all virtual containers myself. Will report back soon.

mibby commented 10 years ago

@Siguza

All seems to be functioning fine now without crashing the client. However, I noticed an item 'shadow' bug.

Virtual anvil. Item in inventory. link

Shift click item into anvil. Creates a duplicate item. link2

Shift click the duplicate item into anvil, item disappears. Item also disappears when moved around. link3

Siguza commented 10 years ago

Should be fixed in build 102.