KeepAlive component for /server (no test)

This commit is contained in:
Tnze
2021-12-22 11:22:11 +08:00
parent 5acd7f73c5
commit 2422e62d17
3 changed files with 177 additions and 7 deletions

View File

@ -2,13 +2,13 @@ package server
import (
_ "embed"
"github.com/Tnze/go-mc/chat"
"github.com/Tnze/go-mc/nbt"
"sync/atomic"
"github.com/google/uuid"
"github.com/Tnze/go-mc/chat"
"github.com/Tnze/go-mc/data/packetid"
"github.com/Tnze/go-mc/nbt"
"github.com/Tnze/go-mc/net"
pk "github.com/Tnze/go-mc/net/packet"
)
@ -34,10 +34,7 @@ var dimensionCodecSNBT string
var dimensionSNBT string
func (g *Game) AcceptPlayer(name string, id uuid.UUID, protocol int32, conn *net.Conn) {
remove := g.PlayerList.TryInsert(PlayerSample{
Name: name,
ID: id,
})
remove := g.PlayerList.TryInsert(PlayerSample{Name: name, ID: id})
if remove == nil {
_ = conn.WritePacket(pk.Marshal(
packetid.ClientboundDisconnect,