public void onItemCraft(ClickInventoryEvent event, @First Player player, @Getter("getTargetInventory") Inventory inventory) { if (inventory.getArchetype() == InventoryArchetypes.WORKBENCH || inventory.getArchetype() == InventoryArchetypes.ANVIL) { event.getTransactions().forEach(slotTransaction -> { if(slotTransaction.getOriginal().get(Keys.ITEM_LORE).isPresent()) { event.setCancelled(true); } }); } }
So I was using this code to block placing items in a workbench or anvil if it had lore, just to stop people from renaming or editing special items. Well the workbench part works just fine, but whenever I try the same item in an anvil the item just disappears and I get the following error.
This only happens when I cancel the event, as I can do anything else to the item just fine.