Uploaded image for project: 'BuildTools'
  1. BuildTools
  2. BUILDTOOLS-205

Player Inventory Content Length and Inventory size mismatch.

XMLWordPrintable

      Cloning an inventory of a player will throw an Illegal Argument exception, as the latest builds of spigot seem to expect a player inventory to be 39 slots, where it is currently 41.

      Example Code:
      {{ Inventory original = player.getInventory();
      Inventory cloned = Bukkit.createInventory(null, original.getType());
      System.out.println("Current inventory size: " + original.getSize() + " Type: " + original.getType() + " Default size: " + original.getType().getDefaultSize());
      System.out.println("Original Inventory Type: " + original.getType());
      System.out.println("Cloned Inventory Type: " + cloned.getType());
      System.out.println("Original Inventory Size: " + original.getSize());
      System.out.println("Cloned Inventory Size: " + cloned.getSize());
      System.out.println("Original Content Size: " + original.getContents().length);
      cloned.setContents(original.getContents()); //This line will throw an exception, because original's contents is larger than original's type max size
      }}

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

              Created:
              Updated:
              Resolved: