Bukkit
  1. Bukkit
  2. BUKKIT-995

getHolder() from an double chest results in null

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Resolution: Fixed
    • Affects Version/s: None
    • Component/s: Bukkit API, Inventory
    • Security Level: Public (Viewable by everyone)
    • Labels:
    • Environment:
      Java: Sun Microsystems Inc. 1.6.0_30
      JVM: Sun Microsystems Inc. Java HotSpot(TM) 64-Bit Server VM 20.5-b03
    • CB Version String:
      This server is running CraftBukkit version git-Bukkit-1.1-R6-32-gf9e35f8-b2033jnks (MC: 1.2.3) (Implementing API version 1.2.3-R0.1-SNAPSHOT)
    • Confirmation Status:
      Unconfirmed

      Description

      Was using the InventoryClickEvent. When a player clicks in the view for the inventory for a double chest, attempting to get the actual Chest using event.getInventory().getHolder() returns a null rather than the Chest object.

      Single chests not affected and return the correct Object. Only double chests are weird.

        Activity

        Hide
        Celtic Minstrel added a comment - - edited

        I think this is actually correct behaviour. A double chest doesn't have a single owner, so there's not really a way to return the holder unless we have some kind of "merged BlockState" or something. You should instead check getLeftHalf().getHolder() and getRightHalf().getHolder(). You'll find they give different chests, naturally.

        Show
        Celtic Minstrel added a comment - - edited I think this is actually correct behaviour. A double chest doesn't have a single owner, so there's not really a way to return the holder unless we have some kind of "merged BlockState" or something. You should instead check getLeftHalf().getHolder() and getRightHalf().getHolder(). You'll find they give different chests, naturally.
        Hide
        Vincent Deloso added a comment - - edited

        Alright, so then how am I supposed to get the DoubleChestInventory object from the InventoryClickEvent to use the methods you have described? Should I just grab the inventory from the event and check if its an instance of DoubleChestInventory?

        ^^
        Yup, that'll do it. Thanks.

        Show
        Vincent Deloso added a comment - - edited Alright, so then how am I supposed to get the DoubleChestInventory object from the InventoryClickEvent to use the methods you have described? Should I just grab the inventory from the event and check if its an instance of DoubleChestInventory? ^^ Yup, that'll do it. Thanks.
        Hide
        Celtic Minstrel added a comment -

        Yes indeed.

        Show
        Celtic Minstrel added a comment - Yes indeed.

          People

          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: