Skip to content

Commit 81f6193

Browse files
committed
/gc command + new text api methods
1 parent 94674ca commit 81f6193

File tree

6 files changed

+121
-8
lines changed

6 files changed

+121
-8
lines changed

commands/commands.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ package commands
33
import "github.com/zeppelinmc/zeppelin/server/command"
44

55
var Commands = []command.Command{
6-
mem, debug, tick, timecmd,
6+
mem, debug, tick, timecmd, gc,
77
}

commands/gc.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package commands
2+
3+
import (
4+
"runtime"
5+
6+
"github.com/zeppelinmc/zeppelin/protocol/text"
7+
"github.com/zeppelinmc/zeppelin/server/command"
8+
)
9+
10+
var gc = command.Command{
11+
Node: command.NewLiteral("gc"),
12+
Namespace: "zeppelin",
13+
Callback: func(ccc command.CommandCallContext) {
14+
runtime.GC()
15+
16+
ccc.Executor.SystemMessage(text.Text("Done.").WithColor(text.BrightGreen))
17+
},
18+
}

protocol/net/packet/play/chunkData.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ type BlockEntity struct {
1616
const PacketIdChunkDataUpdateLight = 0x27
1717

1818
type Heightmaps struct {
19-
MOTION_BLOCKING, WORLD_SURFACE [37]int64
19+
MOTION_BLOCKING, WORLD_SURFACE []int64
2020
}
2121

2222
type ChunkDataUpdateLight struct {

protocol/text/builder.go

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package text
2+
3+
func New() TextComponent {
4+
return TextComponent{}
5+
}
6+
7+
func (t TextComponent) WithColor(c string) TextComponent {
8+
t.Color = c
9+
return t
10+
}
11+
12+
func (t TextComponent) WithText(c string) TextComponent {
13+
t.Text = c
14+
return t
15+
}
16+
17+
func (t TextComponent) WithItalic() TextComponent {
18+
t.Italic = !t.Italic
19+
return t
20+
}
21+
22+
func (t TextComponent) WithUnderline() TextComponent {
23+
t.Underlined = !t.Underlined
24+
return t
25+
}
26+
27+
func (t TextComponent) WithStrikethrough() TextComponent {
28+
t.Strikethrough = !t.Strikethrough
29+
return t
30+
}
31+
32+
func (t TextComponent) WithObfuscation() TextComponent {
33+
t.Obfuscated = !t.Obfuscated
34+
return t
35+
}
36+
37+
func Color(c string) TextComponent {
38+
return TextComponent{Color: c}
39+
}
40+
41+
func Text(c string) TextComponent {
42+
return TextComponent{Text: c}
43+
}
44+
45+
func Italic() TextComponent {
46+
return TextComponent{Italic: true}
47+
}
48+
49+
func Underline() TextComponent {
50+
return TextComponent{Underlined: true}
51+
}
52+
53+
func Strikethrough() TextComponent {
54+
return TextComponent{Strikethrough: true}
55+
}
56+
57+
func Obfuscation() TextComponent {
58+
return TextComponent{Obfuscated: true}
59+
}

protocol/text/color.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package text
2+
3+
import (
4+
"fmt"
5+
"image/color"
6+
)
7+
8+
// colors
9+
const (
10+
Black = "black"
11+
DarkBlue = "dark_blue"
12+
DarkGreen = "dark_green"
13+
DarkCyan = "dark_aqua"
14+
DarkRed = "dark_red"
15+
Purple = "dark_purple"
16+
Gold = "gold"
17+
Gray = "gray"
18+
DarkGray = "dark_gray"
19+
Blue = "blue"
20+
BrightGreen = "green"
21+
Cyan = "aqua"
22+
Red = "red"
23+
Pink = "light_purple"
24+
Yellow = "yellow"
25+
White = "white"
26+
)
27+
28+
func RGB(r, g, b uint8) string {
29+
return fmt.Sprintf("#%02X%02X%02X", r, g, b)
30+
}
31+
32+
func CustomColor(c color.Color) string {
33+
r, g, b, _ := c.RGBA()
34+
35+
return RGB(uint8(r>>8), uint8(g>>8), uint8(b>>8))
36+
}

protocol/text/text.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ package text
44
import "fmt"
55

66
const (
7-
Text = "text"
8-
Translatable = "translatable"
9-
Keybind = "keybind"
10-
Score = "score"
11-
Selector = "selector"
12-
NBT = "nbt"
7+
TypeText = "text"
8+
TypeTranslatable = "translatable"
9+
TypeKeybind = "keybind"
10+
TypeScore = "score"
11+
TypeSelector = "selector"
12+
TypeNBT = "nbt"
1313
)
1414

1515
const (

0 commit comments

Comments
 (0)