Skip to content

Commit

Permalink
server/server.go: Bring back PlayerCount() method.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandertv committed Dec 24, 2024
1 parent 386cf86 commit b2e1d0a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,13 @@ func (srv *Server) MaxPlayerCount() int {
return srv.conf.MaxPlayers
}

// PlayerCount returns the total number of players connected to the Server.
func (srv *Server) PlayerCount() int {
srv.pmu.RLock()
defer srv.pmu.RUnlock()
return len(srv.p)
}

// Players returns an iterator that yields players currently online. If Players
// is called from within a transaction, the respective transaction should be
// passed. Passing nil is otherwise valid. Players returned are only valid
Expand Down

0 comments on commit b2e1d0a

Please sign in to comment.