Can the item a be stacked onto the item b (following max stack size) @param a the item a @param b the item b @return true if they can be merged
(ItemStack a, ItemStack b)
| 322 | * @return true if they can be merged |
| 323 | */ |
| 324 | @SuppressWarnings("deprecation") |
| 325 | public static boolean isMergable(ItemStack a, ItemStack b) { |
| 326 | if (is(a) && is(b)) { |
| 327 | if (!a.getType().equals(b.getType())) { |
| 328 | return false; |
| 329 | } |
| 330 | |
| 331 | if (a.getData().getData() != b.getData().getData()) { |
| 332 | return false; |
| 333 | } |
| 334 | |
| 335 | if (a.hasItemMeta() != b.hasItemMeta()) { |
| 336 | return false; |
| 337 | } |
| 338 | |
| 339 | if (a.getDurability() != b.getDurability()) { |
| 340 | return false; |
| 341 | } |
| 342 | |
| 343 | if (a.hasItemMeta()) { |
| 344 | if (!a.getItemMeta().getDisplayName().equals(b.getItemMeta().getDisplayName())) { |
| 345 | return false; |
| 346 | } |
| 347 | |
| 348 | if (!new ArrayList<String>(a.getItemMeta().getLore()).equals(new ArrayList<>(b.getItemMeta().getLore()))) { |
| 349 | return false; |
| 350 | } |
| 351 | } |
| 352 | |
| 353 | return a.getMaxStackSize() >= a.getAmount() + b.getAmount(); |
| 354 | } |
| 355 | |
| 356 | return false; |
| 357 | } |
| 358 | } |
no test coverage detected