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

Inventory holder returning null

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Invalid
    • Icon: Minor Minor
    • None
    • None
    • None
    • git-Spigot-2040c4c-1872231 (MC: 1.15.2)
    • just my test plugin
    • Yes

      While doing some testing with a plugin of mine, I noticed that an inventory holder in an inventory click event is returning null.

      I created a class which extends InventoryHolder and creates a new inventory which sets said class as the holder, therefor it should NOT be returning null.
      Doing further testing with this class, the inventory is not returning its holder at all, its just always returning null.

      Im adding my little test plugin to show this, simple run the command `/test`, this will open a furnace inventory, observe console. I had it print out inventory and holder, this is the result I'm getting:

      [04:33:12] [Server thread/INFO]: Inv: org.bukkit.craftbukkit.v1_15_R1.inventory.CraftInventoryFurnace@65bda580 Holder: null
      

      As you can see, Holder is returning null, when it should be returning the class holding the inventory.
      I also added into the class a little print message to print the holder when the class is instantiated, result:

      [04:36:08] [Server thread/INFO]: [TesterPlugin] Enabling TesterPlugin v1.0.0
      [04:36:08] [Server thread/INFO]: Holder: null
      

      Code for the plugin's inventory class:

      public class TestInventory implements InventoryHolder {
      
          private final Inventory inventory;
      
          public TestInventory() {
              inventory = Bukkit.createInventory(this, InventoryType.FURNACE);
              TesterPlugin.log("Holder: &b" + inventory.getHolder());
          }
      
          @Override
          public @NotNull Inventory getInventory() {
              return inventory;
          }
      
          public void open(Player player) {
              player.openInventory(inventory);
          }
      
      }
      

      I know you will hate to hear this, but it works as intended on Paper.

            Unassigned Unassigned
            ShaneBee Shane Bee
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: