Skip to content

Commit

Permalink
config.toml: Patched up user config stuff.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandertv committed Dec 22, 2024
1 parent 760af6a commit 6452ff8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 25 deletions.
11 changes: 2 additions & 9 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,10 @@
# The name as it shows up in the server list. Minecraft colour codes may be used in this name to format the
# name of the server.
Name = "Dragonfly Server"
# 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 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 = "%multiplayer.player.joined"
# 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 = "%multiplayer.player.left"
# 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
Expand Down
24 changes: 8 additions & 16 deletions server/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ type Config struct {
// kicking all online players. If set, JoinMessage and QuitMessage must have
// exactly 1 argument, which will be replaced with the name of the player
// joining or quitting.
// ShutdownMessage is set to chat.MessageServerDisconnect if empty.
JoinMessage, QuitMessage, ShutdownMessage chat.Translation
// StatusProvider provides the server status shown to players in the server
// list. By default, StatusProvider will show the server name from the Name
Expand Down Expand Up @@ -134,6 +135,9 @@ func (conf Config) New() *Server {
if conf.MaxChunkRadius == 0 {
conf.MaxChunkRadius = 12
}
if conf.ShutdownMessage.Zero() {
conf.ShutdownMessage = chat.MessageServerDisconnect
}
if len(conf.Entities.Types()) == 0 {
conf.Entities = entity.DefaultRegistry
}
Expand Down Expand Up @@ -185,21 +189,12 @@ type UserConfig struct {
Server struct {
// Name is the name of the server as it shows up in the server list.
Name string
// ShutdownMessage is the message shown to players when the server shuts
// down. If empty, players will be directed to the menu screen right
// away.
ShutdownMessage string
// 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 default join and quit messages
// for players should be disabled.
DisableJoinQuitMessages bool
}
World struct {
// SaveData controls whether a world's data will be saved and loaded.
Expand Down Expand Up @@ -255,11 +250,9 @@ func (uc UserConfig) Config(log *slog.Logger) (Config, error) {
AuthDisabled: !uc.Server.AuthEnabled,
MaxPlayers: uc.Players.MaxCount,
MaxChunkRadius: uc.Players.MaximumChunkRadius,
ShutdownMessage: uc.Server.ShutdownMessage,
DisableResourceBuilding: !uc.Resources.AutoBuildPack,
}
if uc.Server.JoinMessage != "" {
conf.JoinMessage = chat.Translate()
if !uc.Server.DisableJoinQuitMessages {
conf.JoinMessage, conf.QuitMessage = chat.MessageJoin, chat.MessageQuit
}
if uc.World.SaveData {
Expand Down Expand Up @@ -320,7 +313,6 @@ func DefaultConfig() UserConfig {
c := UserConfig{}
c.Network.Address = ":19132"
c.Server.Name = "Dragonfly Server"
c.Server.ShutdownMessage = "Server closed."
c.Server.AuthEnabled = true
c.World.SaveData = true
c.World.Folder = "world"
Expand Down

0 comments on commit 6452ff8

Please sign in to comment.