Skip to content

Commit

Permalink
Fix compile errors
Browse files Browse the repository at this point in the history
  • Loading branch information
renbinden committed Jun 27, 2016
1 parent c338c03 commit 58b8ce3
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.seventh_root.elysium.chat.bukkit.chatchannel.pipeline
import com.seventh_root.elysium.api.chat.ChatChannelPipelineComponent
import com.seventh_root.elysium.api.chat.ChatChannelPipelineComponent.Type.FORMATTER
import com.seventh_root.elysium.api.chat.ChatMessageContext
import com.seventh_root.elysium.api.chat.ChatMessagePostProcessContext
import com.seventh_root.elysium.api.chat.exception.ChatChannelMessageFormattingFailureException
import com.seventh_root.elysium.characters.bukkit.character.BukkitCharacterProvider
import com.seventh_root.elysium.chat.bukkit.ElysiumChatBukkit
Expand Down Expand Up @@ -56,4 +57,39 @@ class BukkitFormatChatChannelPipelineComponent(private val plugin: ElysiumChatBu
return formattedMessage
}

override fun postProcess(message: String, context: ChatMessagePostProcessContext): String? {
val characterProvider = plugin.core.serviceManager.getServiceProvider(BukkitCharacterProvider::class.java)
val sender = context.sender
val senderCharacter = characterProvider.getActiveCharacter(sender)
val chatChannel = context.chatChannel
var formattedMessage = ChatColor.translateAlternateColorCodes('&', formatString)
if (formattedMessage.contains("\$message")) {
formattedMessage = formattedMessage.replace("\$message", message)
}
if (formattedMessage.contains("\$sender-player")) {
formattedMessage = formattedMessage.replace("\$sender-player", sender.name)
}
if (formattedMessage.contains("\$sender-character")) {
if (senderCharacter != null) {
formattedMessage = formattedMessage.replace("\$sender-character", senderCharacter.name)
} else {
throw ChatChannelMessageFormattingFailureException(ChatColor.translateAlternateColorCodes('&', plugin.config.getString("messages.no-character")))
}
}
if (formattedMessage.contains("\$receiver-player")) {
formattedMessage = formattedMessage.replace("\$receiver-player", "\$receiver-player")
}
if (formattedMessage.contains("\$receiver-character")) {
formattedMessage = formattedMessage.replace("\$receiver-character", "\$receiver-character")
}
if (formattedMessage.contains("\$channel")) {
formattedMessage = formattedMessage.replace("\$channel", chatChannel.name)
}
if (formattedMessage.contains("\$color") || formattedMessage.contains("\$colour")) {
val chatColorString = ChatColorUtils.closestChatColorToColor(chatChannel.color).toString()
formattedMessage = formattedMessage.replace("\$color", chatColorString).replace("\$colour", chatColorString)
}
return formattedMessage
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.seventh_root.elysium.chat.bukkit.chatchannel.pipeline
import com.seventh_root.elysium.api.chat.ChatChannelPipelineComponent
import com.seventh_root.elysium.api.chat.ChatChannelPipelineComponent.Type.PRE_PROCESSOR
import com.seventh_root.elysium.api.chat.ChatMessageContext
import com.seventh_root.elysium.api.chat.ChatMessagePostProcessContext
import com.seventh_root.elysium.core.util.MathUtils
import com.seventh_root.elysium.players.bukkit.BukkitPlayer
import org.bukkit.ChatColor
Expand Down Expand Up @@ -35,6 +36,10 @@ class BukkitGarbleChatChannelPipelineComponent(var clearRange: Double) : ChatCha
return message
}

override fun postProcess(message: String, context: ChatMessagePostProcessContext): String? {
return message
}

private fun garbleMessage(message: String, clarity: Double): String {
val newMessage = StringBuilder()
val random = Random()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.seventh_root.elysium.chat.bukkit.chatchannel.pipeline
import com.seventh_root.elysium.api.chat.ChatChannelPipelineComponent
import com.seventh_root.elysium.api.chat.ChatChannelPipelineComponent.Type.POST_PROCESSOR
import com.seventh_root.elysium.api.chat.ChatMessageContext
import com.seventh_root.elysium.api.chat.ChatMessagePostProcessContext

class BukkitIRCChatChannelPipelineComponent(var ircChannel: String?, var isWhitelist: Boolean) : ChatChannelPipelineComponent() {

Expand All @@ -13,4 +14,8 @@ class BukkitIRCChatChannelPipelineComponent(var ircChannel: String?, var isWhite
return message
}

override fun postProcess(message: String, context: ChatMessagePostProcessContext): String? {
return message
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,24 @@ package com.seventh_root.elysium.chat.bukkit.chatchannel.pipeline
import com.seventh_root.elysium.api.chat.ChatChannelPipelineComponent
import com.seventh_root.elysium.api.chat.ChatChannelPipelineComponent.Type.POST_PROCESSOR
import com.seventh_root.elysium.api.chat.ChatMessageContext
import com.seventh_root.elysium.api.chat.ChatMessagePostProcessContext
import java.io.IOException

class BukkitLogChatChannelPipelineComponent : ChatChannelPipelineComponent() {
class BukkitLogChatChannelPipelineComponent: ChatChannelPipelineComponent() {

override val type: ChatChannelPipelineComponent.Type
get() = POST_PROCESSOR

override fun process(message: String, context: ChatMessageContext): String {
return message
}

override fun postProcess(message: String, context: ChatMessagePostProcessContext): String {
try {
context.chatChannel.log(message)
} catch (exception: IOException) {
exception.printStackTrace()
}

return message
}

Expand Down

0 comments on commit 58b8ce3

Please sign in to comment.