RuneHive-Game
Loading...
Searching...
No Matches
CommandEvent.kt
Go to the documentation of this file.
1package org.jire.runehiveps.event.widget
2
3import com.runehive.content.clanchannel.channel.ClanChannel
4import com.runehive.game.event.impl.CommandEvent
5import com.runehive.game.plugin.PluginManager
6import com.runehive.game.world.entity.mob.player.Player
7import com.runehive.game.world.entity.mob.player.command.CommandParser
8import com.runehive.util.Utility
9
10/**
11 * @author Jire
12 */
13class CommandEvent(val input: String) : WidgetEvent {
14
15 override fun handle(player: Player) {
16 val parser = CommandParser.split(input, " ")
17
18 if (parser.command.startsWith("/")) {
19 if (player.punishment.isMuted) {
20 player.message("You can not send clan messages while muted!")
21 return
22 }
23 player.forClan { channel: ClanChannel ->
24 val copy = CommandParser.split(input, "/")
25 if (copy.hasNext()) {
26 val line = copy.nextLine()
27 channel.chat(player.name, Utility.capitalizeSentence(line))
28 }
29 }
30 return
31 }
32
33 PluginManager.getDataBus().publish(player, CommandEvent(parser))
34 }
35
36}