19 : Player) {
20 val used = player.inventory[
slot] ?:
return
21 if (!used.matchesId(itemId)) return
22
23 val npc = World.getNpcBySlot(index).getOrNull() ?: return
24 if (!npc.isValid) return
25
26 val position = npc.position
27 val region = World.getRegions().getRegion(position)
28 if (!region.containsNpc(position.height, npc)) return
29
30 player.walkTo(npc) {
31 player.face(position)
32 if (!PluginManager.getDataBus().publish(player, ItemOnNpcEvent(npc, used,
slot))) {
33 player.send(SendMessage("Nothing interesting happens."))
34 }
35 }
36 }