Hello, I do not know whether this already exists or if it is implemented in the latest builds, at least not in mine. For my plugin I needed a way to access Anvil events, such as item renaming or combining tools to repair them. Maybe someone finds this code useful: Item Renaming Code:java @EventHandler(priority = EventPriority.MONITOR)public void onInventoryClick(InventoryClickEvent e){// check if the event has been cancelled by another pluginif(!e.isCancelled()){HumanEntity ent = e.getWhoClicked(); // not really necessaryif(ent instanceof Player){Player player = (Player)ent;Inventory inv = e.getInventory(); // see if the event is about an anvilif(inv instanceof AnvilInventory){InventoryView view = e.getView();int rawSlot = e.getRawSlot(); // compare the raw slot with the inventory view to make sure we are talking about the upper inventoryif(rawSlot == view.convertSlot(rawSlot)){/*slot 0 = left item slotslot 1 = right item slotslot 2 = result item slot see if the player clicked in the result item slot of the anvil inventory*/if(rawSlot == 2){/*get the current item in the result slotI think inv.getItem(rawSlot) would be possible too*/ItemStack item = e.getCurrentItem(); // check if there is an item in the result slotif(item != null){ItemMeta meta = item.getItemMeta(); // it is possible that the item does not have meta dataif(meta != null){// see whether the item is beeing renamedif(meta.hasDisplayName()){String displayName = meta.getDisplayName(); // do something}}}}}}}}} Item Repairing Code:java @EventHandlerpublic static void onInventoryClick(InventoryClickEvent e){ // check whether the event has been cancelled by another pluginif(!e.isCancelled()){HumanEntity ent = e.getWhoClicked(); // not really necessaryif(ent instanceof Player){Player player = (Player)ent;Inventory inv = e.getInventory(); // see if we are talking about an anvil hereif(inv instanceof AnvilInventory){AnvilInventory anvil = (AnvilInventory)inv;InventoryView view = e.getView();int rawSlot = e.getRawSlot(); // compare raw slot to the inventory view to make sure we are in the upper inventoryif(rawSlot == view.convertSlot(rawSlot)){ // 2 = result slotif(rawSlot == 2){ // all three items in the anvil inventoryItemStack[] items = anvil.getContents(); // item in the left slotItemStack item1 = items[0]; // item in the right slotItemStack item2 = items[1]; // I do not know if this is necessaryif(item1 != null && item2 != null){int id1 = item1.getTypeId();int id2 = item2.getTypeId(); // if the player is repairing something the ids will be the sameif(id1 != 0 && id1 == id2){ // item in the result slotItemStack item3 = e.getCurrentItem(); // check if there is an item in the result slotif(item3 != null){ItemMeta meta = item3.getItemMeta(); // meta data could be nullif(meta != null){ // get the repairable interface to obtain the repair costif(meta instanceof Repairable){Repairable repairable = (Repairable)meta;int repairCost = repairable.getRepairCost(); // can the player afford to repair the itemif(player.getLevel() >= repairCost){// success}else{// bugger}}}}}}}}}}}}
Hi I would really like to know if like I could check what block they are renaming and if it is like mushroom soup it get's cancelled.