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