RuneHive-Game
Loading...
Searching...
No Matches
PickupItemEvent.kt
Go to the documentation of this file.
1package org.jire.runehiveps.event.item
2
3import com.runehive.content.event.EventDispatcher
4import com.runehive.content.event.impl.PickupItemInteractionEvent
5import com.runehive.game.world.entity.mob.player.Player
6import com.runehive.game.world.entity.mob.player.PlayerRight
7import com.runehive.game.world.items.Item
8import com.runehive.game.world.position.Position
9import com.runehive.net.packet.out.SendMessage
10
11/**
12 * @author Jire
13 */
14class PickupItemEvent(
15 val id: Int,
16 val x: Int, val y: Int
17) : ItemEvent {
18
19 override fun handle(player: Player) {
20 val item = Item(id)
21 val position = Position.create(x, y, player.height)
22
23 if (EventDispatcher.execute(player, PickupItemInteractionEvent(item, position))) {
24 if (PlayerRight.isDeveloper(player)) {
25 player.send(
26 SendMessage(
27 String.format(
28 "[%s]: item=%d position=%s",
29 PickupItemInteractionEvent::class.java.simpleName, item.id, position.toString()
30 )
31 )
32 )
33 }
34 return
35 }
36
37 player.pickup(item, position)
38 }
39
40}