func (s *Server) StartServerHandler(player *handler.Player) string { whitelisted := false if len(s.Whitelist) > 0 { for _, whitelisedName := range s.Whitelist { if strings.EqualFold(whitelisedName, player.Username) { whitelisted = true break } } } else { whitelisted = true } if !whitelisted { s.Log("beacon", player.Username+ " is not whitelisted and attempted to start the server.") return chat.Format(s.Messages.MessagePrefix) + "Sorry, you are not whitelisted to start the server!" } s.Log("beacon", player.Username+" started the server.") go s.Restore() return chat.Format(s.Messages.MessagePrefix) + "The server is now starting. Come back in about " + chat.Format(s.Messages.BootTime) + "." }
func (s *Server) setStateRaw(st state) { if s.State == stateStarted || s.State == stateOff { handler.Handle(s.Hostnames, s.ResponseHandler) } switch st { case stateInitializing: s.ConnectMessage = "Sorry, the server is not ready take requests " + "yet!\nTry connecting again in a few seconds." s.PingStatus.Message = chat.Format(s.Messages.ServerInfoPrefix) + chat.Yellow + "Initializing..." s.PingStatus.ShowConnection = false case stateShutdown, stateSnapshot, stateDestroy: s.ConnectMessage = "Sorry, the server is currently shutting down.\n" + "You may start it again when it is completely powered off." s.PingStatus.Message = chat.Format(s.Messages.ServerInfoPrefix) + chat.Yellow + "Shutting down..." s.PingStatus.ShowConnection = false case stateOff: handler.Handle(s.Hostnames, s.StartServerHandler) s.PingStatus.Message = chat.Format(s.Messages.ServerInfoPrefix) + chat.Gold + "Powered off. Connect to start." s.PingStatus.ShowConnection = true case stateStarting: s.ConnectMessage = "Sorry, the server is still starting up.\n" + "Try connecting again in a few minutes." s.PingStatus.Message = chat.Format(s.Messages.ServerInfoPrefix) + chat.LightGreen + "Starting up..." s.PingStatus.ShowConnection = false case stateUnavailable: s.ConnectMessage = "The server isn't available right now.\n" + "Contact " + s.Messages.Owner + " for help." s.PingStatus.Message = chat.Format(s.Messages.ServerInfoPrefix) + chat.Red + "Unavailable." s.PingStatus.ShowConnection = false case stateStarted: s.LastConnectionTime = time.Now() handler.Forward(s.Hostnames, s.IPAddress+":25565") } s.State = st }
func (s *Server) ResponseHandler(player *handler.Player) string { return chat.Format(s.Messages.MessagePrefix + s.ConnectMessage) }