BlockProt

BlockProt

17.2k Downloads

[Bug]: Can Take the Telescope from Menu

TheDiscordian opened this issue ยท 2 comments

commented

Version of BlockProt

blockprot-spigot-1.1.14-all, git-Paper-423 (MC: 1.20.4)

Description of the bug

When viewing the admin menu for locked doors/signs you can remove the telescope "inspect contents" object. An error is displayed in the server console too:

[22:35:24 ERROR]: Could not pass event InventoryClickEvent to BlockProt v1.1.14
java.lang.RuntimeException: Attempting to create a contents inventory for a block without an inventory.
        at de.sean.blockprot.bukkit.inventories.BlockInspectContentsInventory.<init>(BlockInspectContentsInventory.java:47) ~[blockprot-spigot-1.1.14-all-landsfix-final.jar:?]
        at de.sean.blockprot.bukkit.inventories.BlockLockInventory.onClick(BlockLockInventory.java:130) ~[blockprot-spigot-1.1.14-all-landsfix-final.jar:?]
        at de.sean.blockprot.bukkit.listeners.InventoryEventListener.onInventoryClick(InventoryEventListener.java:68) ~[blockprot-spigot-1.1.14-all-landsfix-final.jar:?]
        at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor446.execute(Unknown Source) ~[?:?]
        at org.bukkit.plugin.EventExecutor$2.execute(EventExecutor.java:77) ~[paper-api-1.20.4-R0.1-SNAPSHOT.jar:?]
        at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:81) ~[paper-api-1.20.4-R0.1-SNAPSHOT.jar:git-Paper-423]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[paper-api-1.20.4-R0.1-SNAPSHOT.jar:?]
        at io.papermc.paper.plugin.manager.PaperEventManager.callEvent(PaperEventManager.java:54) ~[paper-1.20.4.jar:git-Paper-423]
        at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.callEvent(PaperPluginManagerImpl.java:126) ~[paper-1.20.4.jar:git-Paper-423]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:615) ~[paper-api-1.20.4-R0.1-SNAPSHOT.jar:?]
        at net.minecraft.server.network.ServerGamePacketListenerImpl.handleContainerClick(ServerGamePacketListenerImpl.java:3106) ~[?:?]
        at net.minecraft.network.protocol.game.ServerboundContainerClickPacket.handle(ServerboundContainerClickPacket.java:58) ~[?:?]
        at net.minecraft.network.protocol.game.ServerboundContainerClickPacket.handle(ServerboundContainerClickPacket.java:23) ~[?:?]
        at net.minecraft.network.protocol.PacketUtils.lambda$ensureRunningOnSameThread$0(PacketUtils.java:54) ~[?:?]
        at net.minecraft.server.TickTask.run(TickTask.java:18) ~[paper-1.20.4.jar:git-Paper-423]
        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:1455) ~[paper-1.20.4.jar:git-Paper-423]
        at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:194) ~[paper-1.20.4.jar:git-Paper-423]
        at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:126) ~[?:?]
        at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:1432) ~[paper-1.20.4.jar:git-Paper-423]
        at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:1355) ~[paper-1.20.4.jar:git-Paper-423]
        at net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:136) ~[?:?]
        at net.minecraft.server.MinecraftServer.waitUntilNextTick(MinecraftServer.java:1333) ~[paper-1.20.4.jar:git-Paper-423]
        at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1222) ~[paper-1.20.4.jar:git-Paper-423]
        at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:319) ~[paper-1.20.4.jar:git-Paper-423]
        at java.lang.Thread.run(Thread.java:840) ~[?:?]

Steps to reproduce

Have user place and lock door.

Have admin open inspect menu and click "Inspect contents", clicking it displays an error, and they can take the item.

Additional context

You can assign this issue to me and I'll work on it.

commented

Thanks for the guidance. This really was only 1 line!

commented

Oh, this is fairly simple. The option to "inspect contents" should probably just be disabled for these blocks. I guess a check similar to the one in the BlockInspectContentsInventory which checks if the block class inherits from InventoryHolder should be used. Should be a one line change when generating the admin menu.