mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-17 19:35:00 -04:00
send chat messages as commands
sending commands (>1.19) is not yet implemented -/-
This commit is contained in:
parent
264d86751a
commit
821b77d6e4
@ -33,7 +33,7 @@ class ChatNode(
|
||||
val string = parser.parse(reader)
|
||||
if (node != CLI.ROOT_NODE && string.isNotBlank()) {
|
||||
if (peek == '/'.code) {
|
||||
stack.connection.util.sendChatMessage("/$string")
|
||||
stack.connection.util.sendCommand("/$string", stack)
|
||||
} else {
|
||||
stack.connection.util.sendChatMessage(string)
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ class SendMessageClickEvent(
|
||||
return
|
||||
}
|
||||
if (!guiRenderer.connection.profiles.gui.confirmation.sendMessage) {
|
||||
guiRenderer.connection.util.sendChatMessage(message)
|
||||
guiRenderer.connection.util.typeChat(message)
|
||||
return
|
||||
}
|
||||
val dialog = SendMessageDialog(guiRenderer, message)
|
||||
|
@ -28,7 +28,7 @@ class SendMessageDialog(
|
||||
override fun createButtons(): Array<ButtonElement> {
|
||||
return arrayOf(
|
||||
ButtonElement(guiRenderer, "Yes, send it!") {
|
||||
guiRenderer.connection.util.sendChatMessage(message)
|
||||
guiRenderer.connection.util.typeChat(message)
|
||||
close()
|
||||
},
|
||||
createCopyToClipboardButton(message)
|
||||
|
@ -32,7 +32,7 @@ class DebugMenu(guiRenderer: GUIRenderer) : Menu(guiRenderer) {
|
||||
init {
|
||||
add(TextElement(guiRenderer, "Debug options", HorizontalAlignments.CENTER, false))
|
||||
add(SpacerElement(guiRenderer, Vec2i(0, 10)))
|
||||
add(ButtonElement(guiRenderer, "Switch to next gamemode") { connection.util.sendChatMessage("/gamemode ${connection.player.gamemode.next().name.lowercase()}") })
|
||||
add(ButtonElement(guiRenderer, "Switch to next gamemode") { connection.util.typeChat("/gamemode ${connection.player.gamemode.next().name.lowercase()}") })
|
||||
add(ButtonElement(guiRenderer, "Hack to next gamemode") {
|
||||
val previous = connection.player.tabListItem.gamemode
|
||||
val next = previous.next()
|
||||
|
@ -15,7 +15,9 @@ package de.bixilon.minosoft.protocol.network.connection.play
|
||||
|
||||
import de.bixilon.kotlinglm.vec3.Vec3d
|
||||
import de.bixilon.kutil.string.WhitespaceUtil.trimWhitespaces
|
||||
import de.bixilon.minosoft.commands.nodes.ChatNode
|
||||
import de.bixilon.minosoft.commands.stack.CommandStack
|
||||
import de.bixilon.minosoft.commands.util.CommandReader
|
||||
import de.bixilon.minosoft.data.chat.message.InternalChatMessage
|
||||
import de.bixilon.minosoft.data.chat.signature.Acknowledgement
|
||||
import de.bixilon.minosoft.data.chat.signature.MessageChain
|
||||
@ -58,6 +60,10 @@ class ConnectionUtil(
|
||||
Log.log(LogMessageType.CHAT_IN, LogLevels.INFO) { prefixed }
|
||||
}
|
||||
|
||||
fun typeChat(message: String) {
|
||||
ChatNode("", allowCLI = false).execute(CommandReader(message), CommandStack(connection))
|
||||
}
|
||||
|
||||
fun sendChatMessage(message: String) {
|
||||
val message = message.trimWhitespaces()
|
||||
if (message.isBlank()) {
|
||||
@ -92,12 +98,11 @@ class ConnectionUtil(
|
||||
connection.sendPacket(SignedChatMessageC2SP(message.encodeNetwork(), time = time, salt = salt, signature = SignatureData(signature), false, acknowledgement))
|
||||
}
|
||||
|
||||
@Deprecated("message will re removed as soon as brigadier is fully implemented")
|
||||
fun sendCommand(message: String, stack: CommandStack) {
|
||||
if (!connection.version.requiresSignedChat || connection.profiles.connection.signature.sendCommandAsMessage) {
|
||||
return sendChatMessage(message)
|
||||
}
|
||||
TODO("Can not send signed chat!")
|
||||
TODO("Can not send signed commands!")
|
||||
}
|
||||
|
||||
fun prepareSpawn() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user