Abstract message coloring into its own class
Move Util to its own package with Color
This commit is contained in:
parent
a56131344b
commit
54eb09c652
|
@ -2,6 +2,8 @@ package civilengineering.bridge
|
||||||
|
|
||||||
import civilengineering.CivilEngineering
|
import civilengineering.CivilEngineering
|
||||||
import civilengineering.cfg
|
import civilengineering.cfg
|
||||||
|
import civilengineering.util.Color
|
||||||
|
import civilengineering.util.color
|
||||||
import net.minecraft.util.text.TextComponentString
|
import net.minecraft.util.text.TextComponentString
|
||||||
import net.minecraftforge.fml.common.FMLCommonHandler
|
import net.minecraftforge.fml.common.FMLCommonHandler
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
|
||||||
|
@ -17,6 +19,7 @@ class ServerChatHelper {
|
||||||
if (nextMessage != null && nextMessage.gateway == cfg!!.connect.gateway) {
|
if (nextMessage != null && nextMessage.gateway == cfg!!.connect.gateway) {
|
||||||
val user = nextMessage.username
|
val user = nextMessage.username
|
||||||
val text = nextMessage.text.trim()
|
val text = nextMessage.text.trim()
|
||||||
|
val chan = nextMessage.channel
|
||||||
|
|
||||||
val message: String
|
val message: String
|
||||||
|
|
||||||
|
@ -26,7 +29,7 @@ class ServerChatHelper {
|
||||||
message = when (event) {
|
message = when (event) {
|
||||||
"user_action" -> "* $user $text"
|
"user_action" -> "* $user $text"
|
||||||
"" -> "<$user> $text"
|
"" -> "<$user> $text"
|
||||||
"join_leave" -> section.toString()+"6-- $user $text"
|
"join_leave" -> "-- $user $text $chan".color(Color.GOLD)
|
||||||
else -> {
|
else -> {
|
||||||
CivilEngineering.logger.debug("Threw out message with unhandled event: $event")
|
CivilEngineering.logger.debug("Threw out message with unhandled event: $event")
|
||||||
CivilEngineering.logger.debug(" Message contents:")
|
CivilEngineering.logger.debug(" Message contents:")
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
package civilengineering.eventhandlers
|
package civilengineering.eventhandlers
|
||||||
|
|
||||||
import civilengineering.Util.antiping
|
import civilengineering.util.Util.antiping
|
||||||
import civilengineering.CivilEngineering
|
|
||||||
import civilengineering.CivilEngineeringConfig
|
|
||||||
import civilengineering.Util
|
|
||||||
import civilengineering.bridge.ApiMessage
|
import civilengineering.bridge.ApiMessage
|
||||||
import civilengineering.bridge.MessageHandler
|
import civilengineering.bridge.MessageHandler
|
||||||
import civilengineering.cfg
|
import civilengineering.cfg
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package civilengineering.eventhandlers
|
package civilengineering.eventhandlers
|
||||||
|
|
||||||
import civilengineering.Util.antiping
|
import civilengineering.util.Util.antiping
|
||||||
import civilengineering.bridge.ApiMessage
|
import civilengineering.bridge.ApiMessage
|
||||||
import civilengineering.bridge.MessageHandler
|
import civilengineering.bridge.MessageHandler
|
||||||
import civilengineering.cfg
|
import civilengineering.cfg
|
||||||
|
|
|
@ -2,7 +2,7 @@ package civilengineering.eventhandlers
|
||||||
|
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
|
||||||
import net.minecraftforge.fml.common.gameevent.PlayerEvent
|
import net.minecraftforge.fml.common.gameevent.PlayerEvent
|
||||||
import civilengineering.Util.antiping
|
import civilengineering.util.Util.antiping
|
||||||
import civilengineering.bridge.ApiMessage
|
import civilengineering.bridge.ApiMessage
|
||||||
import civilengineering.bridge.MessageHandler
|
import civilengineering.bridge.MessageHandler
|
||||||
import civilengineering.cfg
|
import civilengineering.cfg
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
package civilengineering.util
|
||||||
|
|
||||||
|
fun String.color(color: Color):String {
|
||||||
|
return color.code+this
|
||||||
|
}
|
||||||
|
|
||||||
|
enum class Color(val index:Int,val code:String) {
|
||||||
|
BLACK(0,"§0"),
|
||||||
|
DARK_BLUE(1,"§1"),
|
||||||
|
DARK_GREEN(2,"§2"),
|
||||||
|
DARK_AQUA(3,"§3"),
|
||||||
|
DARK_RED(4,"§4"),
|
||||||
|
DARK_PURPLE(5,"§5"),
|
||||||
|
GOLD(6,"§6"),
|
||||||
|
GRAY(7,"§7"),
|
||||||
|
DARK_GRAY(8,"§8"),
|
||||||
|
BLUE(9,"§9"),
|
||||||
|
GREEN(10,"§a"),
|
||||||
|
AQUA(11,"§b"),
|
||||||
|
RED(12,"§c"),
|
||||||
|
LIGHT_PURPLE(13,"§d"),
|
||||||
|
YELLOW(14,"§e"),
|
||||||
|
WHITE(15,"§f")
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package civilengineering
|
package civilengineering.util
|
||||||
|
|
||||||
|
|
||||||
object Util {
|
object Util {
|
Loading…
Reference in New Issue