1package org.jire.runehiveps.event.widget
3import com.runehive.game.world.World
4import com.runehive.game.world.entity.mob.player.Player
5import com.runehive.game.world.entity.mob.player.relations.PrivateChatMessage
6import com.runehive.net.packet.ClientPackets
7import com.runehive.util.ChatCodec
8import com.runehive.util.Utility
9import kotlin.jvm.optionals.getOrNull
14class PlayerRelationEvent(
17 val input: ByteArray? = null
20 override fun handle(player: Player) {
22 ClientPackets.ADD_FRIEND -> player.relations.addFriend(username)
23 ClientPackets.REMOVE_FRIEND -> player.relations.deleteFriend(username)
24 ClientPackets.ADD_IGNORE -> player.relations.addIgnore(username)
25 ClientPackets.REMOVE_IGNORE -> player.relations.deleteIgnore(username)
26 ClientPackets.PRIVATE_MESSAGE -> {
27 val other = World.search(
29 Utility.longToString(username)
31 ).getOrNull() ?: return
33 val decoded = ChatCodec.decode(input)
34 val compressed = ChatCodec.encode(decoded)
36 player.relations.message(other, PrivateChatMessage(decoded, compressed))