diff options
Diffstat (limited to 'server/server.go')
| -rw-r--r-- | server/server.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/server/server.go b/server/server.go index 1bea3cf..2740e09 100644 --- a/server/server.go +++ b/server/server.go @@ -163,6 +163,13 @@ func (s *Server) SendPings() { }) } +func (s *Server) ExecuteCommand( + from CommandSender, auth authLevel, command string) { + s.Act(nil, func() { + executeCommand(s, auth, from, command) + }) +} + func (s *Server) OnDisconnect(cl *client, username string, pl *player) { s.Act(cl, func() { delete(s.clients, cl) @@ -211,6 +218,28 @@ func (s *Server) newPlayer(cl *client, name string) *player { return pl } +func (s *Server) changePlayerAuth( + playerName string, auth authLevel, done func(ok bool)) { + pl := s.players[playerName] + if pl != nil { + pl.SetAuthLevel(s, auth) + pl.Act(s, func() { + done(true) + }) + return + } + loadPlayerData(s, playerName, func(state playerState, ok bool) { + if !ok { + done(false) + return + } + state.Auth = auth + savePlayerData(s, playerName, state, func() { + done(true) + }) + }) +} + func (s *Server) NewPlayer( from phony.Actor, cl *client, name string, reply func(*player)) { s.Act(from, func() { |
