This commit is contained in:
AkmalFairuz
2025-12-11 18:13:35 +07:00
parent 9bf53f12b1
commit 965c8fed4c
2 changed files with 32 additions and 1 deletions

View File

@@ -26,7 +26,7 @@ type CommandOutput struct {
SuccessCount uint32
// OutputMessages is a list of all output messages that should be sent to the player. Whether they are
// shown or not, depends on the type of the messages.
OutputMessages []protocol.CommandOutputMessage
OutputMessages []proto.CommandOutputMessage
// DataSet ... TODO: Find out what this is for.
DataSet protocol.Optional[string]
}

View File

@@ -264,3 +264,34 @@ func CommandOriginData(r protocol.IO, x *protocol.CommandOrigin) {
r.Varint64(&x.PlayerUniqueID)
}
}
// CommandOutputMessage represents a message sent by a command that holds the output of one of the commands
// executed.
type CommandOutputMessage struct {
// Success indicates if the output message was one of a successful command execution. If set to true, the
// output message is by default coloured white, whereas if set to false, the message is by default
// coloured red.
Success bool
// Message is the message that is sent to the client in the chat window. It may either be simply a
// message or a translated built-in string like 'commands.tp.success.coordinates', combined with specific
// parameters below.
Message string
// Parameters is a list of parameters that serve to supply the message sent with additional information,
// such as the position that a player was teleported to or the effect that was applied to an entity.
// These parameters only apply for the Minecraft built-in command output.
Parameters []string
}
// Marshal encodes/decodes a CommandOutputMessage.
func (x *CommandOutputMessage) Marshal(r protocol.IO) {
if IsProtoLT(r, ID898) {
r.Bool(&x.Success)
}
r.String(&x.Message)
if IsProtoGTE(r, ID898) {
r.Bool(&x.Success)
}
r.Bool(&x.Success)
protocol.FuncSlice(r, &x.Parameters, r.String)
}