[SPIGOT-3640] Written books are not counted correctly Created: 06/Nov/17  Updated: 06/Nov/17  Resolved: 06/Nov/17

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

Type: Bug Priority: Minor
Reporter: Vincent Bolta Assignee: Unassigned
Resolution: Invalid Votes: 0
Labels: 1.12.2, bug, inventory, itemstack
Environment:

Windows 8, Minecraft 1.12.2, Spigot 1.12.2. 


Attachments: PNG File Incorrect behavior Spigot.PNG    

 Description   

My plugin uses Inventory.containsAtLeast() to check whether a player has certain items. Generally, it works fine, but for written books it does not. In-game I create a book and sign it and then test to make sure that containsAtLeast() gets it, but it does not.

I think the issue is that a 'real' written book has metadata that should not be checked. Perhaps Itemstack_.isSimilar()_ should check this? 

The figure below shows my findings:

 

 



 Comments   
Comment by Black Hole [ 06/Nov/17 ]

As the JavaDoc for containsAtLeast() states: "Checks if the inventory contains ItemStacks matching the given ItemStack" this method isn't looking for material matches but for itemstack matches. So very attribute of those itemstacks have to match (see ItemMeta). So for example written books with the exact same contents will match.

If you just want to match the material and ignore those attributes use one of the other methods in the Inventory class.

Generated at Fri Mar 14 15:13:02 UTC 2025 using Jira 10.3.3#10030003-sha1:d220e3fefc8dfc6d47f522d3b9a20c1455e12b7b.