(player *Player)
| 48 | } |
| 49 | |
| 50 | func (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 | |
| 74 | func (list *PlayerList) addPlayerToSlice(player *Player) { |
| 75 | pointerOfPlayer := unsafe.Pointer(player) |
no test coverage detected