RuneHive-Game
Loading...
Searching...
No Matches
NpcClickEvent.kt
Go to the documentation of this file.
1package org.jire.runehiveps.event.npc
2
3import com.runehive.game.world.World
4import com.runehive.game.world.entity.mob.data.PacketType
5import com.runehive.game.world.entity.mob.npc.Npc
6import com.runehive.game.world.entity.mob.player.Player
7import kotlin.jvm.optionals.getOrNull
8
9/**
10 * @author Jire
11 */
12interface NpcClickEvent : NpcEvent {
13
14 val slot: Int
15
16 override fun canHandle(player: Player) = super.canHandle(player)
17 && !player.locking.locked(PacketType.CLICK_NPC)
18
19 override fun handle(player: Player) {
20 val npc = World.getNpcBySlot(slot).getOrNull() ?: return
21 if (!npc.isValid) return
22
23 val position = npc.position
24 val region = World.getRegions().getRegion(position)
25 if (!region.containsNpc(position.height, npc)) return
26
27 handleNpc(player, npc)
28 }
29
30 fun handleNpc(player: Player, npc: Npc) {}
31
32}