When a CraftItemStack is internally generated from a NMS ItemStack with a tag of "Damage: 0" (Damageable things in the inventory (sometimes?) have that tag) - it will have an empty ItemMeta (hasItemMeta() == true), Bukkit ItemStacks of damageable items do not have an item meta (if the item is not damaged) (hasItemMeta() == false), so isSimilar will return false.
Reproduction: get the players Inventory and getItem() on some slot with a undamaged damageable item. check .isSimilar() with a new created bukkit itemstack
@EventHandler(priority = EventPriority.NORMAL) public void onJoin(PlayerJoinEvent e) { ItemStack shears = new ItemStack(Material.SHEARS); e.getPlayer().getInventory().setItem(1, shears); System.out.println(e.getPlayer().getInventory().getItem(1).isSimilar(shears)); }
Suggested fix: hasItemMeta() should return false if there is just a single tag of "Damage: 0" and nothing else.
PPS: Bug reports which do not 1) contain a declaration of independence in Vanilla and without plugins, or 2) in the case of plugin API bugs, contain a minimal reproduction case (source + jar please) will be closed. Bug reports must contain step by step instructions to reproduce the bug from a clean server install with no assumptions or prior knowledge. Also make sure you include the full output of /version in your report. Please copy and paste this statement to the bottom of your report to indicate that you have read and understood it.
PPPS: Failure to include the above statement will result in a 24 hour ban from the forums.