RuneHive-Game
Loading...
Searching...
No Matches
InputFieldEvent.kt
Go to the documentation of this file.
1package org.jire.runehiveps.event.widget
2
3import com.runehive.content.DropDisplay
4import com.runehive.content.DropDisplay.DropType
5import com.runehive.content.ProfileViewer
6import com.runehive.content.clanchannel.channel.ClanChannel
7import com.runehive.content.famehall.FameHandler
8import com.runehive.content.simulator.DropSimulator
9import com.runehive.content.store.impl.PersonalStore
10import com.runehive.game.world.World
11import com.runehive.game.world.entity.mob.player.Player
12import com.runehive.game.world.entity.mob.player.PlayerRight
13import com.runehive.net.packet.out.SendMessage
14import com.runehive.util.MessageColor
15
16/**
17 * @author Jire
18 */
19class InputFieldEvent(
20 val component: Int,
21 val context: String
22) : WidgetEvent {
23
24 override fun handle(player: Player) {
25 if (component < 0) return
26
27 if (PlayerRight.isDeveloper(player)) {
28 player.send(
29 SendMessage(
30 "[InputField] - Text: $context Component: $component",
31 MessageColor.DEVELOPER
32 )
33 )
34 }
35
36 when (component) {
37 42102 -> player.forClan { clan: ClanChannel ->
38 if (clan.canManage(clan.getMember(player.name).orElse(null))) {
39 clan.setName(player, context)
40 }
41 }
42
43 42104 -> player.forClan { clan: ClanChannel ->
44 if (clan.canManage(clan.getMember(player.name).orElse(null))) {
45 clan.setTag(player, context)
46 }
47 }
48
49 42106 -> {
50 player.forClan { clan: ClanChannel ->
51 if (clan.canManage(clan.getMember(player.name).orElse(null))) {
52 clan.setSlogan(player, context)
53 }
54 }
55 run {
56 player.forClan { clan: ClanChannel ->
57 if (clan.canManage(clan.getMember(player.name).orElse(null))) {
58 clan.management.password = context
59 if (context.isEmpty()) {
60 player.message("Your clan will no longer use a password.")
61 } else {
62 player.message("The new clan password is: $context.")
63 }
64 }
65 }
66 }
67 }
68
69 42108 -> {
70 player.forClan { clan: ClanChannel ->
71 if (clan.canManage(clan.getMember(player.name).orElse(null))) {
72 clan.management.password = context
73 if (context.isEmpty()) {
74 player.message("Your clan will no longer use a password.")
75 } else {
76 player.message("The new clan password is: $context.")
77 }
78 }
79 }
80 }
81
82 38307 -> PersonalStore.changeName(player, context, false)
83 38309 -> PersonalStore.changeName(player, context, true)
84 26810 -> DropSimulator.drawList(player, context)
85 48508 -> player.priceChecker.searchItem(context)
86 58506 -> FameHandler.search(player, context)
87 57021 -> player.presetManager.name(context)
88 54506 -> DropDisplay.search(player, context, DropType.ITEM)
89 54507 -> DropDisplay.search(player, context, DropType.NPC)
90 353 -> {
91 if (World.search(context).isPresent) {
92 ProfileViewer.open(player, World.search(context).get())
93 return
94 }
95 player.send(SendMessage("You can not view $context's profile as they are currently offline."))
96 }
97
98 354 -> if (PlayerRight.isModerator(player)) {
99 if (World.search(context).isPresent) {
100 //StaffPanel.search(player, context);
101 return
102 }
103 player.send(SendMessage("You can not manage $context as they are currently offline."))
104 }
105 }
106 }
107
108}