Documentation ¶
Overview ¶
Package chat implements Minecraft's chat message encoding system.
The type Message is the Minecraft chat message. Can be encode as JSON or net/packet.Field .
It's very recommended that use SetLanguage before using Message.String or Message.ClearString, or the `github.com/VacPlusPlus/go-mc/data/en-us` will be used. Note: The package of data/lang/... will SetLanguage on theirs init() so you don't need to call by your self.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetLanguage ¶
SetLanguage set the translate map to this map.
Types ¶
type Message ¶
type Message jsonChat
Message is a message sent by other
func TranslateMsg ¶
Example ¶
package main import ( "fmt" "github.com/VacPlusPlus/go-mc/chat" ) func main() { fmt.Println(chat.TranslateMsg("translation.test.none")) fmt.Println(chat.TranslateMsg( // translation.test.complex == "Prefix, %s%[2]s again %s and %[1]s lastly %s and also %[1]s again!" "translation.test.complex", chat.Text("1111"), chat.Text("2222"), chat.Text("3333"), ).String()) }
Output: Hello, world! Prefix, 11112222 again 3333 and 1111 lastly 2222 and also 1111 again!
func (*Message) Append ¶
Example ¶
package main import ( "fmt" "github.com/VacPlusPlus/go-mc/chat" ) func main() { msg := chat.Message{Text: "1111"} msg.Append( chat.Message{Text: "22222"}, chat.Message{Text: "333333"}, chat.Message{Text: "4444444"}, ) fmt.Print(msg) }
Output: 1111222223333334444444
func (Message) ClearString ¶
ClearString return the message String without escape sequence for ansi color.
func (Message) String ¶
String return the message string with escape sequence for ansi color. To convert Translated Message to string, you must set On windows, you may want print this string using github.com/matte/go-colorable.
func (*Message) UnmarshalJSON ¶
UnmarshalJSON decode json to Message