MCPcopy Create free account
hub / github.com/ZeppelinMC/Zeppelin / SprintText

Function SprintText

util/log/log.go:49–76  ·  view source on GitHub ↗
(msg text.TextComponent)

Source from the content-addressed store, hash-verified

47}
48
49func SprintText(msg text.TextComponent) string {
50 str := strs.Get().(*strings.Builder)
51 str.Reset()
52 defer strs.Put(str)
53
54 var components = append([]text.TextComponent{msg}, msg.Extra...)
55 for _, component := range components {
56 c := colors[component.Color]
57 if c == nil {
58 c = colors["white"]
59 }
60 if component.Bold {
61 c = c.Add(color.Bold)
62 }
63 if component.Strikethrough {
64 c = c.Add(color.CrossedOut)
65 }
66 if component.Underlined {
67 c = c.Add(color.Underline)
68 }
69 if component.Italic {
70 c = c.Add(color.Italic)
71 }
72 str.WriteString(c.Sprint(component.Text))
73 }
74
75 return strings.ReplaceAll(str.String(), "\n", "\n\r")
76}
77
78var colors = map[string]*color.Color{
79 "black": color.New(color.FgBlack),

Callers 1

ChatFunction · 0.85

Calls 3

GetMethod · 0.45
AddMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected