internal chat: differentiate between debug and internal messages

This commit is contained in:
Bixilon 2022-05-21 14:14:14 +02:00
parent 06e3b386dd
commit 2dda35ea74
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
4 changed files with 25 additions and 15 deletions

View File

@ -18,6 +18,6 @@ import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
class PlayerPrintTarget(val connection: PlayConnection) : PrintTarget {
override fun print(message: Any) {
connection.util.sendDebugMessage(message)
connection.util.sendInternal(message)
}
}

View File

@ -29,6 +29,7 @@ object RenderConstants {
const val COLORMAP_SIZE = 255
const val DEBUG_MESSAGES_PREFIX = "§f[§e§lDEBUG§f] "
const val INTERNAL_MESSAGES_PREFIX = "§f[§a§lINTERNAL§f] "
val TEXT_BACKGROUND_COLOR = RGBColor(0, 0, 0, 80)

View File

@ -76,17 +76,18 @@ class ScreenshotTaker(
ImageIO.write(bufferedImage, "png", file)
var deleted = false
renderWindow.connection.util.sendDebugMessage(BaseComponent(
"§aScreenshot saved: ",
TextComponent(file.name).apply {
color = ChatColors.WHITE
underline()
clickEvent = OpenFileClickEvent(file.slashPath)
hoverEvent = TextHoverEvent("Click to open")
},
" ",
TextComponent("[DELETE]").apply {
color = ChatColors.RED
renderWindow.connection.util.sendInternal(
BaseComponent(
"§aScreenshot saved: ",
TextComponent(file.name).apply {
color = ChatColors.WHITE
underline()
clickEvent = OpenFileClickEvent(file.slashPath)
hoverEvent = TextHoverEvent("Click to open")
},
" ",
TextComponent("[DELETE]").apply {
color = ChatColors.RED
bold()
clickEvent = ClickCallbackClickEvent {
if (deleted) {
@ -113,7 +114,7 @@ class ScreenshotTaker(
private fun Throwable?.fail() {
this?.printStackTrace()
renderWindow.connection.util.sendDebugMessage("§cFailed to make a screenshot: ${this?.message}")
renderWindow.connection.util.sendInternal("§cFailed to make a screenshot: ${this?.message}")
}
companion object {

View File

@ -33,8 +33,16 @@ class ConnectionUtil(
) {
fun sendDebugMessage(message: Any) {
connection.fireEvent(InternalMessageReceiveEvent(connection, BaseComponent(RenderConstants.DEBUG_MESSAGES_PREFIX, ChatComponent.of(message).apply { applyDefaultColor(ChatColors.BLUE) })))
Log.log(LogMessageType.CHAT_IN, LogLevels.INFO) { message }
val component = BaseComponent(RenderConstants.DEBUG_MESSAGES_PREFIX, ChatComponent.of(message).apply { applyDefaultColor(ChatColors.BLUE) })
connection.fireEvent(InternalMessageReceiveEvent(connection, component))
Log.log(LogMessageType.CHAT_IN, LogLevels.INFO) { component }
}
fun sendInternal(message: Any) {
val component = ChatComponent.of(message)
val prefixed = BaseComponent(RenderConstants.INTERNAL_MESSAGES_PREFIX, component)
connection.fireEvent(InternalMessageReceiveEvent(connection, if (connection.profiles.gui.chat.internal.hidden) prefixed else component))
Log.log(LogMessageType.CHAT_IN, LogLevels.INFO) { prefixed }
}
fun sendChatMessage(message: String) {