Implemented Global Chat
Added global chat feature, so players can still maintain global communication while being in their own clan chat An individual player can opt out of global chat by using the ::muteglobal command Implemented automatic message splitting for clan and global chat Implemented colour selection for global chat (prefix your message with hex colour code, e.g. //%690420 before the message)
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package core.game.system.communication
|
||||
|
||||
import core.api.Commands
|
||||
import core.api.getAttribute
|
||||
import core.api.sendMessage
|
||||
import core.api.setAttribute
|
||||
import core.game.system.command.Privilege
|
||||
import core.game.world.repository.Repository
|
||||
import core.tools.colorize
|
||||
|
||||
class GlobalChat : Commands {
|
||||
override fun defineCommands() {
|
||||
define("muteglobal", Privilege.STANDARD, "", "Toggles global chat on or off.") {player, _ ->
|
||||
val original = getAttribute(player, ATTR_GLOBAL_MUTE, false)
|
||||
setAttribute(player, ATTR_GLOBAL_MUTE, !original)
|
||||
sendMessage(player, "Global chat is now ${if (original) "ON" else "OFF"}.")
|
||||
return@define
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
val ATTR_GLOBAL_MUTE = "/save:globalmute"
|
||||
fun process(sender: String, message: String) {
|
||||
val msgSD = prepare(sender, message, false)
|
||||
val msgHD = prepare(sender, message, true)
|
||||
for (player in Repository.players.filter { !getAttribute(it, ATTR_GLOBAL_MUTE, false) }) {
|
||||
if (player.interfaceManager.isResizable)
|
||||
sendMessage(player, msgHD)
|
||||
else
|
||||
sendMessage(player, msgSD)
|
||||
}
|
||||
}
|
||||
|
||||
private fun prepare(sender: String, message: String, isResizable: Boolean): String {
|
||||
val baseColor = if (isResizable) "%G" else "%7512ff"
|
||||
val bracketColor = if (isResizable) "%ffffff" else "%000000"
|
||||
return colorize("$bracketColor[${baseColor}G$bracketColor] $sender: ${baseColor}$message")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -133,6 +133,7 @@ object ServerConfigParser {
|
||||
ServerConstants.DISCORD_MOD_WEBHOOK = data.getString("server.moderation_webhook", "")
|
||||
ServerConstants.NOAUTH_DEFAULT_ADMIN = data.getBoolean("server.noauth_default_admin", false)
|
||||
ServerConstants.DRAGON_AXE_USE_OSRS_SPEC = data.getBoolean("world.dragon_axe_use_osrs_spec", false)
|
||||
ServerConstants.ENABLE_GLOBALCHAT = data.getBoolean("world.enable_globalchat", true)
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user