Skip to main content

Server settings

TavernLib.Backend.Server.Configs.ServerSettings and ServerSettingsConfig in TavernLib.dll. Server only.

server_settings.json: the server's name, password, player limit, listing and so on. Read it through TavernManager.ServerConfig. What each setting means to a host is in the config reference.

ServerSettings​

public class ServerSettings

Every property is read-only from a mod: the setters are private or internal. You can read settings but not change them through Update.

PropertyJSON keyDefault
string Namename"My Tavern Server"
string PasswordHashpassword_hash"" (no password)
string Passwordpasswordnull. Never set after a read, see below.
bool WhitelistEnabledwhitelist_enabledfalse
bool EnforceIpLimitenforce_ip_limittrue (at most 5 accounts registered from one address, as in the Windows launcher)
bool CommunityListedcommunity_listedfalse
int MaxPlayersmax_players24
string CommunityListingTokencommunity_listing_token"", then made for you
string PublicHostnamepublic_hostnamenull
bool QuestScenequest_scenefalse
bool TutorialScenetutorial_scenefalse
string Regionregion"unknown"
float GarbageCollectionTimergarbage_collection_timer30
float ServerBackupTimeserver_backup_time0 (off)
int ServerBackupMaxBackupsserver_backup_max_backups0 (keep all)
bool ConsoleOwnerLocalOnlyconsole_owner_local_onlyfalse
Other memberWhat it is
const int DefaultMaxPlayers = 24The Windows launcher's default too.
int PlayerLimit { get; }MaxPlayers if it's above 0, else DefaultMaxPlayers. Not in the JSON. Use this, not MaxPlayers: an older file can have 0.

Unknown keys are kept and written back.

The player limit​

TavernLib postfixes the game's ServerHandler.PlayerLimit getter to return ServerConfig.LastRead.PlayerLimit. So a new value shows the next time TavernLib reads the file, which is the next login or join (see How fresh is LastRead?). The listing reports ServerHandler.Current.PlayerLimit.

TavernLib's join check (its replacement for the game's CheckIfPlayerIsAllowedCustom, see Internals) refuses a join once the socket's connection count goes past the limit, with the game's own message, "Reached player limit of: 24". The joining player's connection is already counted, so with max_players at 24 the 25th player is the one turned away.

To refuse joins for your own reasons, postfix CheckIfPlayerIsAllowedCustom. The Joining page has an example.

If your mod patches ServerHandler.PlayerLimit too, both postfixes run, and whichever runs last wins. Harmony runs lower priorities later, so [HarmonyPriority(Priority.Low)] on yours makes it win. Hosts expect max_players to work, so think twice.

ServerSettingsConfig​

public class ServerSettingsConfig(string filePath) : ServerConfigFile<ServerSettings>(filePath)

Adds two things to ServerConfigFile:

Password tidy-up (in Tidy, so on every read):

  • A password key holds a password typed in by hand. It's hashed into password_hash and the password key is removed from the file. An empty password is just removed, leaving password_hash as it was.
  • A password_hash that isn't 64 lower-case hex characters is taken as a plain password typed into the wrong key (AMP's password field does this), and hashed too.
  • The hash is SHA-256 of the SHA-256 of the password, each as lower-case hex. That's what the launcher writes and what joins are checked against. To check a password from your mod, compare against that, never against Password.

Listing token (in ReadFromFile only): if community_listing_token is empty after the read, it makes a random URL-safe token and writes the file. Read() doesn't do this.

When settings take effect​

TavernLib reads most of these as it needs them, so a host's change usually works without a restart:

SettingApplies
name, password_hash, whitelist_enabled, enforce_ip_limitOn the next login or join.
max_playersOn the next read, see above.
console_owner_local_onlyOn the next console login.
garbage_collection_timerWhen the game's GarbageCollectTimer component starts.
server_backup_time, server_backup_max_backupsWithin a minute. Headless servers only.
community_listedAt start.
quest_scene, tutorial_sceneNever by themselves. The scene comes from /questScene or /tutorialScene on the command line, which launchers add from these keys. TavernLib also reads the keys to say which scene the listing shows.

See also​