Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-4741

InventoryHolder no longer returns as instance of DoubleChest for double chests.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • This server is running CraftBukkit version git-Spigot-f2180d5-2cc992e (MC: 1.14 Pre-Release 5) (Implementing API version 1.14-pre5-SNAPSHOT)
    • Yes

      In Spigot 1.14 Pre-5, you can no longer determine if a chest is a DoubleChest.

      Normally, InventoryHolder can be detected as an instance of DoubleChest.

      In 1.13, the following code detects if you right click on a double chest:

      @EventHandler(priority = EventPriority.LOWEST)
              protected void onPlayerInteract(PlayerInteractEvent event) {
                  if (event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
                      if (event.getClickedBlock().getType().equals(Material.CHEST)) {
                          System.out.println("Right clicked a chest! Determining type...");
                          Chest chest = (Chest) event.getClickedBlock().getState();
                          InventoryHolder holder = chest.getInventory().getHolder();
                          if (holder instanceof DoubleChest) {
                              System.out.println("Clicked a double chest!");
                          }
                          else {
                              System.out.println("Clicked a single chest!");
                          }
                      }
                  }
              }
      

      However, in 1.14, this code returns "Clicked a single chest!" for both double chests and single chests.

      I've attached an example plugin for reproducing the issue. The plugin works as expected in Spigot 1.13, but not in Spigot 1.14-Pre5.

      Thanks

            Unassigned Unassigned
            Intelli Intelli
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: