mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-15 18:34:56 -04:00
brigadier: print error messages red, print correct error client sided if stack is empty
This commit is contained in:
parent
acc668916e
commit
dea78c8611
@ -39,9 +39,14 @@ class ChatNode(
|
||||
thrown = error
|
||||
}
|
||||
|
||||
|
||||
if (node != CLI.ROOT_NODE && string.isNotBlank()) {
|
||||
if (peek == '/'.code) {
|
||||
stack.connection.util.sendCommand("/$string", stack)
|
||||
try {
|
||||
stack.connection.util.sendCommand("/$string", stack)
|
||||
} catch (error: Throwable) {
|
||||
throw thrown ?: error
|
||||
}
|
||||
} else {
|
||||
stack.connection.util.sendChatMessage(string)
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||
* Copyright (C) 2020-2023 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
@ -24,6 +24,8 @@ import de.bixilon.minosoft.commands.stack.print.PlayerPrintTarget
|
||||
import de.bixilon.minosoft.commands.util.CommandReader
|
||||
import de.bixilon.minosoft.commands.util.StringReader.Companion.isWord
|
||||
import de.bixilon.minosoft.config.key.KeyCodes
|
||||
import de.bixilon.minosoft.data.text.TextComponent
|
||||
import de.bixilon.minosoft.data.text.formatting.color.ChatColors
|
||||
import de.bixilon.minosoft.gui.rendering.gui.GUIRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.Element
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.text.mark.TextCursorStyles
|
||||
@ -89,7 +91,7 @@ class NodeTextInputElement(
|
||||
try {
|
||||
node.execute(CommandReader(value), stack)
|
||||
} catch (exception: Throwable) {
|
||||
exception.message?.let { stack.print.print(it) }
|
||||
exception.message?.let { stack.print.print(TextComponent("Error: $it").color(ChatColors.RED)) }
|
||||
}
|
||||
updateError(null)
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||
* Copyright (C) 2020-2023 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
@ -21,6 +21,8 @@ import de.bixilon.minosoft.commands.nodes.LiteralNode
|
||||
import de.bixilon.minosoft.commands.parser.minosoft.connection.ConnectionParser
|
||||
import de.bixilon.minosoft.commands.parser.minosoft.connection.ConnectionTarget
|
||||
import de.bixilon.minosoft.commands.stack.CommandStack
|
||||
import de.bixilon.minosoft.data.text.TextComponent
|
||||
import de.bixilon.minosoft.data.text.formatting.color.ChatColors
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.terminal.cli.CLI
|
||||
|
||||
@ -32,7 +34,7 @@ object ConnectionManageCommand : Command {
|
||||
connections += PlayConnection.ERRORED_CONNECTIONS.toSynchronizedList()
|
||||
val filteredConnections = it.get<ConnectionTarget?>("filter")?.getConnections(connections) ?: connections
|
||||
if (filteredConnections.isEmpty()) {
|
||||
it.print.print("No connection matched your filter!")
|
||||
it.print.print(TextComponent("No connection matched your filter!").color(ChatColors.RED))
|
||||
return@LiteralNode
|
||||
}
|
||||
val table = Table(arrayOf("Id", "State", "Address"))
|
||||
@ -63,13 +65,13 @@ object ConnectionManageCommand : Command {
|
||||
continue
|
||||
}
|
||||
if (toSelect != null) {
|
||||
stack.print.print("Can not select multiple connections!")
|
||||
stack.print.print(TextComponent("Can not select multiple connections!").color(ChatColors.RED))
|
||||
return@addFilter
|
||||
}
|
||||
toSelect = connection
|
||||
}
|
||||
if (toSelect == null) {
|
||||
stack.print.print("No connection matched your filter!")
|
||||
stack.print.print(TextComponent("No connection matched your filter!").color(ChatColors.RED))
|
||||
return@addFilter
|
||||
}
|
||||
CLI.connection = toSelect
|
||||
@ -85,7 +87,7 @@ object ConnectionManageCommand : Command {
|
||||
connections += PlayConnection.ERRORED_CONNECTIONS.toSynchronizedList()
|
||||
val filteredConnections = it.get<ConnectionTarget?>("filter")?.getConnections(connections) ?: connections
|
||||
if (filteredConnections.isEmpty()) {
|
||||
it.print.print("No connection matched your filter!")
|
||||
it.print.print(TextComponent("No connection matched your filter!").color(ChatColors.RED))
|
||||
return@ArgumentNode
|
||||
}
|
||||
executor(it, connections)
|
||||
|
Loading…
x
Reference in New Issue
Block a user