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

Method handleNewConnection

server/server.go:197–213  ·  view source on GitHub ↗
(conn *net.Conn)

Source from the content-addressed store, hash-verified

195}
196
197func (srv *Server) handleNewConnection(conn *net.Conn) {
198 log.Infolnf("%sPlayer attempting to connect: %s (%s)", log.FormatAddr(srv.cfg.LogIPs, conn.RemoteAddr()), conn.Username(), conn.UUID())
199 if p := srv.playerList.PlayerByUsername(conn.Username()); p != nil {
200 _ = conn.WritePacket(&configuration.Disconnect{
201 Reason: text.TextComponent{Text: "You are already connected to the server from another session. Please disconnect then try again"},
202 })
203 return
204 }
205 playerData, err := srv.World.PlayerData(conn.UUID().String())
206 if err != nil {
207 playerData = srv.World.NewPlayerData(conn.UUID())
208 }
209
210 playerState := srv.Players.New(playerData)
211
212 go srv.playerList.New(conn, playerState, &srv.World.DimensionManager, &srv.World.Level, &srv.cfg, srv.CommandManager).Login()
213}
214
215func (srv *Server) Stop() {
216 log.InfolnClean("Stopping server")

Callers 1

StartMethod · 0.95

Calls 11

InfolnfFunction · 0.92
FormatAddrFunction · 0.92
UsernameMethod · 0.80
PlayerByUsernameMethod · 0.80
WritePacketMethod · 0.80
PlayerDataMethod · 0.80
NewPlayerDataMethod · 0.80
LoginMethod · 0.80
NewMethod · 0.65
UUIDMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected