Skip to content

Commit 21f83ab

Browse files
committed
add test and format code
1 parent 1f60837 commit 21f83ab

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

pkg/edition/java/cookie/cookie.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,3 @@ func Request(ctx context.Context, c Client, key key.Key, eventMgr event.Manager)
7575
func RequestAndForget(c Client, key key.Key) error {
7676
return requestAndForget(c, key)
7777
}
78-

pkg/edition/java/proto/packet/packet_test.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,17 @@ import (
1010
"encoding/gob"
1111
"encoding/json"
1212
"fmt"
13-
"go.minekube.com/common/minecraft/key"
14-
"go.minekube.com/gate/pkg/edition/java/proto/nbtconv"
15-
"go.minekube.com/gate/pkg/edition/java/proto/packet/config"
16-
"go.minekube.com/gate/pkg/edition/java/proto/util"
1713
"io"
1814
"reflect"
1915
"testing"
2016
"time"
2117

18+
"go.minekube.com/common/minecraft/key"
19+
"go.minekube.com/gate/pkg/edition/java/proto/nbtconv"
20+
"go.minekube.com/gate/pkg/edition/java/proto/packet/config"
21+
"go.minekube.com/gate/pkg/edition/java/proto/packet/cookie"
22+
"go.minekube.com/gate/pkg/edition/java/proto/util"
23+
2224
"github.com/go-faker/faker/v4"
2325
"github.com/stretchr/testify/assert"
2426
"github.com/stretchr/testify/require"
@@ -270,6 +272,9 @@ var packets = []proto.Packet{
270272
&config.TagsUpdate{},
271273
&RemoveResourcePack{},
272274
&LoginAcknowledged{},
275+
&cookie.CookieRequest{Key: key.New("minecraft", "test")},
276+
&cookie.CookieResponse{Key: key.New("minecraft", "test"), Payload: []byte("payload")},
277+
&cookie.CookieStore{Key: key.New("minecraft", "test"), Payload: []byte("payload")},
273278
}
274279

275280
func generatePlayerKey() crypto.IdentifiedKey {

pkg/edition/java/proxy/events.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,16 +1286,16 @@ func (e *CookieStoreEvent) SetAllowed(allowed bool) { e.denied = !allowed }
12861286
// by a backend server. Gate will wait on this event to finish firing before discarding the
12871287
// cookie request (if handled) or forwarding it to the client.
12881288
type CookieRequestEvent struct {
1289-
player Player
1290-
key key.Key
1289+
player Player
1290+
key key.Key
12911291
originalKey key.Key
12921292
denied bool
12931293
}
12941294

12951295
func newCookieRequestEvent(player Player, key key.Key) *CookieRequestEvent {
12961296
return &CookieRequestEvent{
1297-
player: player,
1298-
key: key,
1297+
player: player,
1298+
key: key,
12991299
originalKey: key,
13001300
denied: false,
13011301
}

pkg/edition/java/proxy/session_backend_play.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,6 @@ func (b *backendPlaySessionHandler) handleCookieRequest(p *cookie.CookieRequest)
498498
forwardCookieRequest(e, b.serverConn.player)
499499
}
500500

501-
502501
// prefer PacketContext over Packet
503502
//
504503
// since we already have the packet's payload we can simply forward it on,

0 commit comments

Comments
 (0)