diff --git a/config.toml b/config.toml index d2cd5ea61..2968671c0 100644 --- a/config.toml +++ b/config.toml @@ -11,20 +11,16 @@ # The message shown to players when the server is shutting down. The message may be left empty to direct # players to the server list directly. ShutdownMessage = "Server closed." - # AuthEnabled controls whether or not players must be connected to Xbox Live in order to join the server. + # AuthEnabled controls whether players must be connected to Xbox Live in order to join the server. AuthEnabled = true - # JoinMessage is the message that appears when a player joins the server. Leave this empty to disable it. - # %v is the placeholder for the username of the player. Set this to "" to disable. - JoinMessage = "%v has joined the game" - # QuitMessage is the message that appears when a player leaves the server. Leave this empty to disable it. - # %v is the placeholder for the username of the player. Set this to "" to disable. - QuitMessage = "%v has left the game" + # DisableJoinQuitMessages specifies if join/quit messages should be broadcast when players join the server. + DisableJoinQuitMessages = false [World] # The folder that the world files (will) reside in, relative to the working directory. If not currently # present, the folder will be made. Folder = "world" - # Whether or not the worlds' data will be saved and loaded. If true, the server will use the + # Whether the worlds' data will be saved and loaded. If true, the server will use the # default LevelDB data provider and if false, an empty provider will be used. To use your # own provider, turn this value to false, as you will still be able to pass your own provider. SaveData = true @@ -36,7 +32,7 @@ # The maximum chunk radius that players may set in their settings. If they try to set it above this number, # it will be capped and set to the max. MaximumChunkRadius = 32 - # Whether or not a player's data will be saved and loaded. If true, the server will use the + # Whether a player's data will be saved and loaded. If true, the server will use the # default LevelDB data provider and if false, an empty provider will be used. To use your # own provider, turn this value to false, as you will still be able to pass your own provider. SaveData = true @@ -49,5 +45,5 @@ AutoBuildPack = true # Folder configures the directory used by the server to load resource packs. Folder = "resources" - # Required configures whether or not the server will require players to have a resource pack to join. + # Required configures whether the server will require players to have a resource pack to join. Required = true diff --git a/server/conf.go b/server/conf.go index 77bd2e733..788721a8c 100644 --- a/server/conf.go +++ b/server/conf.go @@ -62,12 +62,12 @@ type Config struct { // MaxChunkRadius is the maximum view distance that each player may have, // measured in chunks. A chunk radius generally leads to more memory usage. MaxChunkRadius int - // JoinMessage, QuitMessage and ShutdownMessage are the messages to send for - // when a player joins or quits the server and when the server shuts down, - // kicking all online players. JoinMessage and QuitMessage may have a '%v' - // argument, which will be replaced with the name of the player joining or - // quitting. - JoinMessage, QuitMessage, ShutdownMessage string + // DisableJoinQuitMessages specifies if join/quit messages should be + // broadcast when players join the server. + DisableJoinQuitMessages bool + // ShutdownMessage is the message sent when the server shuts down, kicking + // all online players. + ShutdownMessage string // StatusProvider provides the server status shown to players in the server // list. By default, StatusProvider will show the server name from the Name // field and the current player count and maximum players. @@ -191,14 +191,9 @@ type UserConfig struct { // AuthEnabled controls whether players must be connected to Xbox Live // in order to join the server. AuthEnabled bool - // JoinMessage is the message that appears when a player joins the - // server. Leave this empty to disable it. %v is the placeholder for the - // username of the player - JoinMessage string - // QuitMessage is the message that appears when a player leaves the - // server. Leave this empty to disable it. %v is the placeholder for the - // username of the player - QuitMessage string + // DisableJoinQuitMessages specifies if the default join/quit messages + // should be broadcast when players join/quit the server. + DisableJoinQuitMessages bool } World struct { // SaveData controls whether a world's data will be saved and loaded. @@ -254,8 +249,7 @@ func (uc UserConfig) Config(log *slog.Logger) (Config, error) { AuthDisabled: !uc.Server.AuthEnabled, MaxPlayers: uc.Players.MaxCount, MaxChunkRadius: uc.Players.MaximumChunkRadius, - JoinMessage: uc.Server.JoinMessage, - QuitMessage: uc.Server.QuitMessage, + DisableJoinQuitMessages: uc.Server.DisableJoinQuitMessages, ShutdownMessage: uc.Server.ShutdownMessage, DisableResourceBuilding: !uc.Resources.AutoBuildPack, } @@ -319,8 +313,6 @@ func DefaultConfig() UserConfig { c.Server.Name = "Dragonfly Server" c.Server.ShutdownMessage = "Server closed." c.Server.AuthEnabled = true - c.Server.JoinMessage = "%v has joined the game" - c.Server.QuitMessage = "%v has left the game" c.World.SaveData = true c.World.Folder = "world" c.Players.MaximumChunkRadius = 32 diff --git a/server/server.go b/server/server.go index c21c9bf93..601ff1337 100644 --- a/server/server.go +++ b/server/server.go @@ -523,11 +523,10 @@ func (srv *Server) createPlayer(id uuid.UUID, conn session.Conn, conf player.Con srv.pwg.Add(1) s := session.Config{ - Log: srv.conf.Log, - MaxChunkRadius: srv.conf.MaxChunkRadius, - JoinMessage: srv.conf.JoinMessage, - QuitMessage: srv.conf.QuitMessage, - HandleStop: srv.handleSessionClose, + Log: srv.conf.Log, + MaxChunkRadius: srv.conf.MaxChunkRadius, + DisableJoinQuitMessages: srv.conf.DisableJoinQuitMessages, + HandleStop: srv.handleSessionClose, }.New(conn) conf.Name = conn.IdentityData().DisplayName diff --git a/server/session/session.go b/server/session/session.go index 46f714512..363a5cb67 100644 --- a/server/session/session.go +++ b/server/session/session.go @@ -82,8 +82,6 @@ type Session struct { openChunkTransactions []map[uint64]struct{} invOpened bool - joinMessage, quitMessage string - closeBackground chan struct{} } @@ -132,7 +130,7 @@ type Config struct { MaxChunkRadius int - JoinMessage, QuitMessage string + DisableJoinQuitMessages bool HandleStop func(*world.Tx, Controllable) } @@ -162,8 +160,6 @@ func (conf Config) New(conn Conn) *Session { conn: conn, currentEntityRuntimeID: 1, heldSlot: new(uint32), - joinMessage: conf.JoinMessage, - quitMessage: conf.QuitMessage, recipes: make(map[uint32]recipe.Recipe), conf: conf, } @@ -223,7 +219,7 @@ func (s *Session) Spawn(c Controllable, tx *world.Tx) { s.sendInv(s.armour.Inventory(), protocol.WindowIDArmour) chat.Global.Subscribe(c) - if s.joinMessage != "" { + if !s.conf.DisableJoinQuitMessages { chat.Global.Writet(chat.MessageJoin, s.conn.IdentityData().DisplayName) } @@ -254,7 +250,7 @@ func (s *Session) close(tx *world.Tx, c Controllable) { s.chunkLoader.Close(tx) - if s.quitMessage != "" { + if !s.conf.DisableJoinQuitMessages { chat.Global.Writet(chat.MessageQuit, s.conn.IdentityData().DisplayName) } chat.Global.Unsubscribe(c)