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

Method AddPlayer

server/player/playerlist.go:50–72  ·  view source on GitHub ↗
(player *Player)

Source from the content-addressed store, hash-verified

48}
49
50func (list *PlayerList) AddPlayer(player *Player) {
51 list.addPlayerToSlice(player)
52
53 update := &play.PlayerInfoUpdate{
54 Actions: play.ActionAddPlayer | play.ActionUpdateListed, //todo: add the rest
55 Players: make(map[uuid.UUID]play.PlayerAction, list.NumPlayers()),
56 }
57
58 for i := uintptr(0); i < list.playerList.Len(); i++ {
59 player := list.playerAtIndex(i)
60
61 update.Players[player.UUID()] = play.PlayerAction{
62 Name: player.Username(),
63 Listed: !player.Unlisted,
64 Properties: player.Properties(),
65 }
66 }
67
68 for i := uintptr(0); i < list.playerList.Len(); i++ {
69 player := list.playerAtIndex(i)
70 player.writeOrKill(update)
71 }
72}
73
74func (list *PlayerList) addPlayerToSlice(player *Player) {
75 pointerOfPlayer := unsafe.Pointer(player)

Callers 1

startGameMethod · 0.80

Calls 8

addPlayerToSliceMethod · 0.95
NumPlayersMethod · 0.95
playerAtIndexMethod · 0.95
LenMethod · 0.80
UsernameMethod · 0.80
writeOrKillMethod · 0.80
UUIDMethod · 0.45
PropertiesMethod · 0.45

Tested by

no test coverage detected