[SPIGOT-5070] isOpenable for InventoryHolder Created: 14/Jun/19  Updated: 20/Jun/19

Status: Open
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: New Feature Priority: Minor
Reporter: Photon Assignee: Unassigned
Resolution: Unresolved Votes: 1
Labels: Inventory, Openable

Version: This server is running CraftBukkit version git-Spigot-df0eb25-411609d (MC: 1.14.2) (Implementing API version 1.14.2-R0.1-SNAPSHOT)
Guidelines Read: Yes

 Description   

Please add a method to check if a certain InventoryHolder's Inventory can be opened because there are several hard-to-check-for ways that this could be blocked:

  • Some materials above chests/enderchests allow for opening, some don't
  • A cat sitting on top of a chest
  • Double chest handling is even more complicated in those cases.
  • Some InventoryHolders don't have such requirements at all (like furnaces)

Therefore an isOpenable method that checks on the serverside if a player would be able to open a certain container would be very helpful and makes code much more elegant as lots of special cases could be avoided.



 Comments   
Comment by Yannick Lamprecht [ 20/Jun/19 ]

I assume you want to check the holder isOpenable before you access the container using Player#openInventory ?

Comment by Cynthia Yantis [ 16/Jun/19 ]

I feel as if this would only be used in a select few cases, and anyways, why would you not just listen for an InventoryOpenEvent and then modify that? To me it seems like an easier solution on both ends of the situation.

Generated at Fri Mar 14 09:35:29 UTC 2025 using Jira 10.3.3#10030003-sha1:d220e3fefc8dfc6d47f522d3b9a20c1455e12b7b.