Skip to content

Commit

Permalink
Begin of Minecraft_1_20_2 support development
Browse files Browse the repository at this point in the history
  • Loading branch information
robinbraemer committed Dec 16, 2023
1 parent 2fa3d97 commit ed2c859
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 20 deletions.
6 changes: 3 additions & 3 deletions pkg/edition/java/proto/codec/encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
)

const (
VanillaMaximumUncompressedSize = 8 * 1024 * 1024 // 8MiB
HardMaximumUncompressedSize = 16 * 1024 * 1024 // 16MiB
VanillaMaximumUncompressedSize = 8 * 1024 * 1024 // 8MiB
HardMaximumUncompressedSize = 128 * 1024 * 1024 // 128MiB
UncompressedCap = VanillaMaximumUncompressedSize
)

Expand All @@ -30,7 +30,7 @@ type Encoder struct {
hexDump bool // for debugging

mu sync.Mutex // Protects following fields
wr io.Writer // the underlying writer to write successfully encoded packet to
wr io.Writer // the underlying writer to write successfully encoded packets to
registry *state.ProtocolRegistry
state *state.Registry
compression struct {
Expand Down
6 changes: 4 additions & 2 deletions pkg/edition/java/proto/state/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,12 @@ func versionRange(versions []*proto.Version, from, to proto.Protocol, fn func(pr
// String implements fmt.Stringer.
func (s State) String() string {
switch s {
case StatusState:
return "Status"
case HandshakeState:
return "Handshake"
case StatusState:
return "Status"
case ConfigState:
return "Config"
case LoginState:
return "Login"
case PlayState:
Expand Down
9 changes: 5 additions & 4 deletions pkg/edition/java/proto/state/states.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ type State int

// The states the Java edition client connection can be in.
const (
HandshakeState State = iota
StatusState
LoginState
PlayState
HandshakeState State = 0
StatusState State = 1
ConfigState State = 4 // Minecraft 1.20.2+: After StatusState, before LoginState
LoginState State = 2
PlayState State = 3
)

// The registries storing the packets for a connection state.
Expand Down
3 changes: 2 additions & 1 deletion pkg/edition/java/proto/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ var (
Minecraft_1_19_3 = &proto.Version{Protocol: 761, Names: s("1.19.3")}
Minecraft_1_19_4 = &proto.Version{Protocol: 762, Names: s("1.19.4")}
Minecraft_1_20 = &proto.Version{Protocol: 763, Names: s("1.20", "1.20.1")}
Minecraft_1_20_2 = &proto.Version{Protocol: 764, Names: s("1.20.2")}

// Versions ordered from lowest to highest
Versions = []*proto.Version{
Expand All @@ -59,7 +60,7 @@ var (
Minecraft_1_17, Minecraft_1_17_1,
Minecraft_1_18, Minecraft_1_18_2,
Minecraft_1_19, Minecraft_1_19_1, Minecraft_1_19_3, Minecraft_1_19_4,
Minecraft_1_20,
Minecraft_1_20, Minecraft_1_20_2,
}
)

Expand Down
6 changes: 1 addition & 5 deletions pkg/edition/java/proxy/builtin_cmd_glist.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
. "go.minekube.com/common/minecraft/color"
. "go.minekube.com/common/minecraft/component"
"go.minekube.com/gate/pkg/command"
"go.minekube.com/gate/pkg/command/suggest"
)

const glistCmdPermission = "gate.command.glist"
Expand All @@ -23,10 +22,7 @@ func newGlistCmd(proxy *Proxy) brigodier.LiteralNodeBuilder {
return c.SendMessage(glistTotalCount(proxy.PlayerCount()))
})).
Then(brigodier.Argument(glistServerArg, brigodier.String).
Suggests(command.SuggestFunc(func(_ *command.Context,
b *brigodier.SuggestionsBuilder) *brigodier.Suggestions {
return suggest.Similar(b, append(serverNames(proxy), "all")).Build()
})).
Suggests(serverSuggestionProvider(proxy, "all")).
Executes(command.Command(func(c *command.Context) error {
return glistSendServerCount(proxy, c.Source, c.String(glistServerArg))
})),
Expand Down
5 changes: 3 additions & 2 deletions pkg/edition/java/proxy/builtin_cmd_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,13 @@ func sortServers(s []RegisteredServer) {
})
}

func serverSuggestionProvider(p *Proxy) brigodier.SuggestionProvider {
func serverSuggestionProvider(p *Proxy, additionalServers ...string) brigodier.SuggestionProvider {
return command.SuggestFunc(func(
_ *command.Context,
b *brigodier.SuggestionsBuilder,
) *brigodier.Suggestions {
return suggest.Similar(b, serverNames(p)).Build()
candidates := append(serverNames(p), additionalServers...)
return suggest.Similar(b, candidates).Build()
})
}

Expand Down
5 changes: 2 additions & 3 deletions pkg/util/permission/permission.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
// The permission utility package defines primitives that allow to
// check a Subject for a permission.
// Package permission is a utility package that defines primitives to allow checking a Subject for a permission.
//
// E.g. A player's permission Func can be setup on join by subscribing
// to proxy.PermissionsSetupEvent.
//
// Note:
// This is a simple package only allowing limited complexity of permission checking
// and may not suffice everyone's requirements.
// Therefore Gate also makes no assumptions on whether this package is used or not.
// Therefore, Gate also makes no assumptions on whether this package is used or not.
// Plugins may use their own authorization system internally without a touch on this package.
package permission

Expand Down

0 comments on commit ed2c859

Please sign in to comment.