RuneHive-Game
Loading...
Searching...
No Matches
DropdownMenuEvent.kt
Go to the documentation of this file.
1package org.jire.runehiveps.event.widget
2
3import com.runehive.content.clanchannel.ClanRank
4import com.runehive.content.clanchannel.ClanRepository
5import com.runehive.content.clanchannel.ClanType
6import com.runehive.content.clanchannel.channel.ClanChannel
7import com.runehive.content.clanchannel.content.ClanViewer
8import com.runehive.content.simulator.DropSimulator
9import com.runehive.content.simulator.Simulation
10import com.runehive.game.world.entity.mob.player.Player
11import com.runehive.game.world.entity.mob.player.PlayerRight
12import com.runehive.net.packet.out.SendMessage
13import com.runehive.util.MessageColor
14
15/**
16 * @author Jire
17 */
18class DropdownMenuEvent(
19 val identification: Int,
20 val value: Int
21) : WidgetEvent {
22
23 override fun handle(player: Player) {
24 if (player.debug && PlayerRight.isDeveloper(player)) {
25 player.send(
26 SendMessage(
27 "[DropdownMenuPacketListener] Identification: $identification | Value: $value",
28 MessageColor.DEVELOPER
29 )
30 )
31 }
32
33 when (identification) {
34 43019 -> {
35 player.clanViewer.filter = ClanViewer.Filter.values()[value]
36 player.clanViewer.open(player.clanChannel, ClanViewer.ClanTab.OVERVIEW)
37 }
38
39 42110 -> player.forClan { channel: ClanChannel ->
40 if (channel.canManage(channel.getMember(player.name).orElse(null))) {
41 ClanRepository.getTopChanels(channel.details.type)
42 .ifPresent { set: MutableSet<ClanChannel?> ->
43 set.remove(
44 channel
45 )
46 }
47 channel.details.type = ClanType.values()[value]
48 ClanRepository.getTopChanels(ClanType.values()[value])
49 .ifPresent { set: MutableSet<ClanChannel?> ->
50 set.add(
51 channel
52 )
53 }
54 ClanRepository.ALLTIME.add(channel)
55 player.clanViewer.update(channel)
56 }
57 }
58
59 42112 -> player.forClan { channel: ClanChannel ->
60 if (channel.canManage(channel.getMember(player.name).orElse(null))) {
61 channel.management.setEnterRank(ClanRank.values()[value])
62 player.clanViewer.update(channel)
63 }
64 }
65
66 42114 -> player.forClan { channel: ClanChannel ->
67 if (channel.canManage(channel.getMember(player.name).orElse(null))) {
68 channel.management.setTalkRank(ClanRank.values()[value])
69 player.clanViewer.update(channel)
70 }
71 }
72
73 42116 -> player.forClan { channel: ClanChannel ->
74 if (channel.canManage(channel.getMember(player.name).orElse(null))) {
75 channel.management.setManageRank(ClanRank.values()[value])
76 player.clanViewer.update(channel)
77 }
78 }
79
80 42134 -> {
81 var color: String? = null
82 when (value) {
83 0 -> color = "<col=ffffff>"
84 1 -> color = "<col=F03737>"
85 2 -> color = "<col=2ADE36>"
86 3 -> color = "<col=2974FF>"
87 4 -> color = "<col=EBA226>"
88 5 -> color = "<col=A82D81>"
89 6 -> color = "<col=FF57CA>"
90 }
91 val col = color
92 player.forClan { channel: ClanChannel ->
93 if (channel.canManage(channel.getMember(player.name).orElse(null))) {
94 channel.color = col
95 player.clanViewer.update(channel)
96 }
97 }
98 }
99
100 26811 -> {
101 val simulations = intArrayOf(10, 100, 1000, 10000, 100000)
102 val simulatorNpc = player.attributes.get<String, Int>("DROP_SIMULATOR_KEY")
103 DropSimulator.simulate(player, Simulation.NPC_DROP, simulatorNpc, simulations[value])
104 }
105 }
106 }
107
108}