using Rests;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Text;
namespace TShockAPI.Configuration
{
///
/// Settings used in the TShock configuration file
///
public class TShockSettings
{
#region Server Settings
/// The server password required to join the server.
[Description("The server password required to join the server.")]
public string ServerPassword = "";
/// The port the server runs on.
[Description("The port the server runs on.")]
public int ServerPort = 7777;
/// Maximum number of clients connected at once. If lower than Terraria's setting, the server will kick excess connections.
[Description("Maximum number of clients connected at once.\nIf you want people to be kicked with \"Server is full\" set this to how many players you want max and then set Terraria max players to 2 higher.")]
public int MaxSlots = 8;
/// The number of reserved slots past your max server slots that can be joined by reserved players.
[Description("The number of reserved slots past your max server slots that can be joined by reserved players.")]
public int ReservedSlots = 20;
/// Replaces the world name during a session if UseServerName is true.
[Description("Replaces the world name during a session if UseServerName is true.")]
public string ServerName = "";
/// Whether or not to use ServerName in place of the world name.
[Description("Whether or not to use ServerName in place of the world name.")]
public bool UseServerName = false;
/// The path to the directory where logs should be written to.
[Description("The path to the directory where logs should be written to.")]
public string LogPath = "tshock/logs";
/// Whether or not the server should output debug level messages related to system operation.
[Description("Whether or not the server should output debug level messages related to system operation.")]
public bool DebugLogs = false;
/// Prevents users from being able to login before they finish connecting.
[Description("Prevents users from being able to login before they finish connecting.")]
public bool DisableLoginBeforeJoin;
/// Allows stacks in chests to go beyond the stack limit during world loading.
[Description("Allows stacks in chests to go beyond the stack limit during world loading.")]
public bool IgnoreChestStacksOnLoad = false;
#endregion
#region Backup and Save Settings
/// Enable or disable Terraria's built-in world auto save.
[Description("Enable or disable Terraria's built-in world auto save.")]
public bool AutoSave = true;
/// Enable or disable world save announcements.
[Description("Enable or disable world save announcements.")]
public bool AnnounceSave = true;
/// Whether or not to show backup auto save messages.
[Description("Whether or not to show backup auto save messages.")]
public bool ShowBackupAutosaveMessages = true;
/// The interval between backups, in minutes. Backups are stored in the tshock/backups folder.
[Description("The interval between backups, in minutes. Backups are stored in the tshock/backups folder.")]
public int BackupInterval = 10;
/// For how long backups are kept in minutes.
[Description("For how long backups are kept in minutes.\neg. 2880 = 2 days.")]
public int BackupKeepFor = 240;
/// Whether or not to save the world if the server crashes from an unhandled exception.
[Description("Whether or not to save the world if the server crashes from an unhandled exception.")]
public bool SaveWorldOnCrash = true;
/// Whether or not to save the world when the last player disconnects.
[Description("Whether or not to save the world when the last player disconnects.")]
public bool SaveWorldOnLastPlayerExit = true;
#endregion
#region World Settings
/// Determines the size of invasion events. The equation for calculating invasion size = 100 + (multiplier * (number of active players > 200 hp)).
[Description("Determines the size of invasion events.\nThe equation for calculating invasion size is 100 + (multiplier * (number of active players with greater than 200 health)).")]
public int InvasionMultiplier = 1;
/// The default maximum number of mobs that will spawn per wave. Higher means more mobs in that wave.
[Description("The default maximum number of mobs that will spawn per wave. Higher means more mobs in that wave.")]
public int DefaultMaximumSpawns = 5;
/// The delay between waves. Lower values lead to more mobs.
[Description("The delay between waves. Lower values lead to more mobs.")]
public int DefaultSpawnRate = 600;
/// Enables never-ending invasion events. You still need to start the event.
[Description("Enables never ending invasion events. You still need to start the event, such as with the /invade command.")]
public bool InfiniteInvasion;
/// Sets the PvP mode. Valid types are: "normal", "always", "disabled".
[Description("Sets the PvP mode. Valid types are: \"normal\", \"always\" and \"disabled\".")]
public string PvPMode = "normal";
/// Prevents tiles from being placed within SpawnProtectionRadius of the default spawn.
[Description("Prevents tiles from being placed within SpawnProtectionRadius of the default spawn.")]
public bool SpawnProtection = true;
/// The tile radius around the spawn tile that is protected by the SpawnProtection setting.
[Description("The tile radius around the spawn tile that is protected by the SpawnProtection setting.")]
public int SpawnProtectionRadius = 10;
/// Enable or disable anti-cheat range checks based on distance between the player and their block placements.
[Description("Enable or disable anti-cheat range checks based on distance between the player and their block placements.")]
public bool RangeChecks = true;
/// Prevents non-hardcore players from connecting.
[Description("Prevents non-hardcore players from connecting.")]
public bool HardcoreOnly;
/// Prevents softcore players from connecting.
[Description("Prevents softcore players from connecting.")]
public bool MediumcoreOnly;
/// Prevents non-softcore players from connecting.
[Description("Prevents non-softcore players from connecting.")]
public bool SoftcoreOnly;
/// Disables any placing, or removal of blocks.
[Description("Disables any placing, or removal of blocks.")]
public bool DisableBuild;
/// If enabled, hardmode will not be activated by the Wall of Flesh or the /starthardmode command.
[Description("If enabled, hardmode will not be activated by the Wall of Flesh or the /starthardmode command.")]
public bool DisableHardmode;
/// Prevents the dungeon guardian from being spawned while sending players to their spawn point instead.
[Description("Prevents the dungeon guardian from being spawned while sending players to their spawn point instead.")]
public bool DisableDungeonGuardian;
/// Disables clown bomb projectiles from spawning.
[Description("Disables clown bomb projectiles from spawning.")]
public bool DisableClownBombs;
/// Disables snow ball projectiles from spawning.
[Description("Disables snow ball projectiles from spawning.")]
public bool DisableSnowBalls;
/// Disables tombstone dropping during death for all players.
[Description("Disables tombstone dropping during death for all players.")]
public bool DisableTombstones = true;
///
/// Disables Skeletron Prime Bombs from spawning, useful for preventing unwanted world destruction on for the worthy seed world.
///
[Description("Disables Skeletron Prime Bombs from spawning, useful for preventing unwanted world destruction on for the worthy seed world.")]
public bool DisablePrimeBombs;
/// Forces the world time to be normal, day, or night.
[Description("Forces the world time to be normal, day, or night.")]
public string ForceTime = "normal";
/// Disables the effect of invisibility potions while PvP is enabled by turning the player visible to the other clients.
[Description("Disables the effect of invisibility potions while PvP is enabled by turning the player visible to the other clients.")]
public bool DisableInvisPvP;
/// The maximum distance, in tiles, that disabled players can move from.
[Description("The maximum distance, in tiles, that disabled players can move from.")]
public int MaxRangeForDisabled = 10;
/// Whether or not region protection should apply to chests.
[Description("Whether or not region protection should apply to chests.")]
public bool RegionProtectChests;
/// Whether or not region protection should apply to gem locks.
[Description("Whether or not region protection should apply to gem locks.")]
public bool RegionProtectGemLocks = true;
/// Ignores checks to see if a player 'can' update a projectile.
[Description("Ignores checks to see if a player 'can' update a projectile.")]
public bool IgnoreProjUpdate = false;
/// Ignores checks to see if a player 'can' kill a projectile.
[Description("Ignores checks to see if a player 'can' kill a projectile.")]
public bool IgnoreProjKill = false;
/// Allows players to break temporary tiles (grass, pots, etc) where they cannot usually build.
[Description("Allows players to break temporary tiles (grass, pots, etc) where they cannot usually build.")]
public bool AllowCutTilesAndBreakables = false;
/// Allows ice placement even where a user cannot usually build.
[Description("Allows ice placement even where a user cannot usually build.")]
public bool AllowIce = false;
/// Allows the crimson to spread when a world is in hardmode.
[Description("Allows the crimson to spread when a world is in hardmode.")]
public bool AllowCrimsonCreep = true;
/// Allows the corruption to spread when a world is in hardmode.
[Description("Allows the corruption to spread when a world is in hardmode.")]
public bool AllowCorruptionCreep = true;
/// Allows the hallow to spread when a world is in hardmode.
[Description("Allows the hallow to spread when a world is in hardmode.")]
public bool AllowHallowCreep = true;
/// How many NPCs a statue can spawn within 200 pixels(?) before it stops spawning.
[Description("How many NPCs a statue can spawn within 200 pixels(?) before it stops spawning.\nDefault = 3.")]
public int StatueSpawn200 = 3;
/// How many NPCs a statue can spawn within 600 pixels(?) before it stops spawning.
[Description("How many NPCs a statue can spawn within 600 pixels(?) before it stops spawning.\nDefault = 6.")]
public int StatueSpawn600 = 6;
/// How many NPCs a statue can spawn before it stops spawning.
[Description("How many NPCs a statue can spawn before it stops spawning.\nDefault = 10.")]
public int StatueSpawnWorld = 10;
/// Prevent banned items from being spawned or given with commands.
[Description("Prevent banned items from being spawned or given with commands.")]
public bool PreventBannedItemSpawn = false;
/// Prevent players from interacting with the world while they are dead.
[Description("Prevent players from interacting with the world while they are dead.")]
public bool PreventDeadModification = true;
/// Prevents players from placing tiles with an invalid style.
[Description("Prevents players from placing tiles with an invalid style.")]
public bool PreventInvalidPlaceStyle = true;
/// Forces Christmas-only events to occur all year.
[Description("Forces Christmas-only events to occur all year.")]
public bool ForceXmas = false;
/// Forces Halloween-only events to occur all year.
[Description("Forces Halloween-only events to occur all year.")]
public bool ForceHalloween = false;
/// Allows groups on the banned item allowed list to spawn banned items even if PreventBannedItemSpawn is set to true.
[Description("Allows groups on the banned item allowed list to spawn banned items even if PreventBannedItemSpawn is set to true.")]
public bool AllowAllowedGroupsToSpawnBannedItems = false;
/// The number of seconds a player must wait before being respawned. Valid range: 0 (default) to 15 seconds. Use at your own risk.
[Description("The number of seconds a player must wait before being respawned. Valid range: 0 (default) to 15 seconds. Use at your own risk.")]
public int RespawnSeconds = 0;
/// The number of seconds a player must wait before being respawned if there is a boss nearby. Valid range: 0 (default) to 30 seconds. Use at your own risk.
[Description("The number of seconds a player must wait before being respawned if there is a boss nearby. Valid range: 0 (default) to 30 seconds. Use at your own risk.")]
public int RespawnBossSeconds = 0;
/// Whether or not to announce boss spawning or invasion starts.
[Description("Whether or not to announce boss spawning or invasion starts.")]
public bool AnonymousBossInvasions = true;
/// The maximum HP a player can have, before equipment buffs.
[Description("The maximum HP a player can have, before equipment buffs.")]
public int MaxHP = 500;
/// The maximum MP a player can have, before equipment buffs.
[Description("The maximum MP a player can have, before equipment buffs.")]
public int MaxMP = 200;
/// Determines the range in tiles that a bomb can affect tiles from detonation point.
[Description("Determines the range in tiles that a bomb can affect tiles from detonation point.")]
public int BombExplosionRadius = 5;
#endregion
#region Login and Ban Settings
/// The default group name to place newly registered users under.
[Description("The default group name to place newly registered users under.")]
public string DefaultRegistrationGroupName = "default";
/// The default group name to place unregistered players under.
[Description("The default group name to place unregistered players under.")]
public string DefaultGuestGroupName = "guest";
/// Remembers where a player left off, based on their IP. Does not persist through server restarts.
[Description("Remembers where a player left off, based on their IP. Does not persist through server restarts.\neg. When you try to disconnect, and reconnect to be automatically placed at spawn, you'll be at your last location.")]
public bool RememberLeavePos;
/// Number of failed login attempts before kicking the player.
[Description("Number of failed login attempts before kicking the player.")]
public int MaximumLoginAttempts = 3;
/// Whether or not to kick mediumcore players on death.
[Description("Whether or not to kick mediumcore players on death.")]
public bool KickOnMediumcoreDeath;
/// The reason given if kicking a mediumcore players on death.
[Description("The reason given if kicking a mediumcore players on death.")]
public string MediumcoreKickReason = "Death results in a kick";
/// Whether or not to ban mediumcore players on death.
[Description("Whether or not to ban mediumcore players on death.")]
public bool BanOnMediumcoreDeath;
/// The reason given if banning a mediumcore player on death.
[Description("The reason given if banning a mediumcore player on death.")]
public string MediumcoreBanReason = "Death results in a ban";
/// Enable or disable the whitelist based on IP addresses in the whitelist.txt file.
[Description("Enable or disable the whitelist based on IP addresses in the whitelist.txt file.")]
public bool EnableWhitelist;
/// The reason given when kicking players for not being on the whitelist.
[Description("The reason given when kicking players for not being on the whitelist.")]
public string WhitelistKickReason = "You are not on the whitelist.";
/// The reason given when kicking players that attempt to join while the server is full.
[Description("The reason given when kicking players that attempt to join while the server is full.")]
public string ServerFullReason = "Server is full";
/// The reason given when kicking players that attempt to join while the server is full with no reserved slots available.
[Description("The reason given when kicking players that attempt to join while the server is full with no reserved slots available.")]
public string ServerFullNoReservedReason = "Server is full. No reserved slots open.";
/// Whether or not to kick hardcore players on death.
[Description("Whether or not to kick hardcore players on death.")]
public bool KickOnHardcoreDeath;
/// The reason given when kicking hardcore players on death.
[Description("The reason given when kicking hardcore players on death.")]
public string HardcoreKickReason = "Death results in a kick";
/// Whether or not to ban hardcore players on death.
[Description("Whether or not to ban hardcore players on death.")]
public bool BanOnHardcoreDeath;
/// The reason given when banning hardcore players on death.
[Description("The reason given when banning hardcore players on death.")]
public string HardcoreBanReason = "Death results in a ban";
/// If GeoIP is enabled, this will kick users identified as being under a proxy.
[Description("If GeoIP is enabled, this will kick users identified as being under a proxy.")]
public bool KickProxyUsers = true;
/// Require all players to register or login before being allowed to play.
[Description("Require all players to register or login before being allowed to play.")]
public bool RequireLogin;
/// Allows users to login to any account even if the username doesn't match their character name.
[Description("Allows users to login to any account even if the username doesn't match their character name.")]
public bool AllowLoginAnyUsername = true;
/// Allows users to register a username that doesn't necessarily match their character name.
[Description("Allows users to register a username that doesn't necessarily match their character name.")]
public bool AllowRegisterAnyUsername;
/// The minimum password length for new user accounts. Can never be lower than 4.
[Description("The minimum password length for new user accounts. Can never be lower than 4.")]
public int MinimumPasswordLength = 4;
/// The hash algorithm used to encrypt user passwords.
/// Valid types: "sha512", "sha256" and "md5". Append with "-xp" for the xp supported algorithms.
[Description("The hash algorithm used to encrypt user passwords. Valid types: \"sha512\", \"sha256\" and \"md5\". Append with \"-xp\" for the xp supported algorithms.")]
public string HashAlgorithm = "sha512";
/// Determines the BCrypt work factor to use. If increased, all passwords will be upgraded to new work-factor on verify.
/// The number of computational rounds is 2^n. Increase with caution. Range: 5-31.
[Description("Determines the BCrypt work factor to use. If increased, all passwords will be upgraded to new work-factor on verify. The number of computational rounds is 2^n. Increase with caution. Range: 5-31.")]
public int BCryptWorkFactor = 7;
/// Prevents users from being able to login with their client UUID.
[Description("Prevents users from being able to login with their client UUID.")]
public bool DisableUUIDLogin;
/// Kick clients that don't send their UUID to the server.
[Description("Kick clients that don't send their UUID to the server.")]
public bool KickEmptyUUID;
/// Disables a player if this number of tiles is painted within 1 second.
[Description("Disables a player if this number of tiles is painted within 1 second.")]
public int TilePaintThreshold = 15;
/// Whether or not to kick users when they surpass the TilePaint threshold.
[Description("Whether or not to kick users when they surpass the TilePaint threshold.")]
public bool KickOnTilePaintThresholdBroken = false;
/// The maximum damage a player/NPC can inflict.
[Description("The maximum damage a player/NPC can inflict.")]
public int MaxDamage = 1175;
/// The maximum damage a projectile can inflict.
[Description("The maximum damage a projectile can inflict.")]
public int MaxProjDamage = 1175;
/// Whether or not to kick users when they surpass the MaxDamage threshold.
[Description("Whether or not to kick users when they surpass the MaxDamage threshold.")]
public bool KickOnDamageThresholdBroken = false;
/// Disables a player and reverts their actions if this number of tile kills is exceeded within 1 second.
[Description("Disables a player and reverts their actions if this number of tile kills is exceeded within 1 second.")]
public int TileKillThreshold = 60;
/// Whether or not to kick users when they surpass the TileKill threshold.
[Description("Whether or not to kick users when they surpass the TileKill threshold.")]
public bool KickOnTileKillThresholdBroken = false;
/// Disables a player and reverts their actions if this number of tile places is exceeded within 1 second.
[Description("Disables a player and reverts their actions if this number of tile places is exceeded within 1 second.")]
public int TilePlaceThreshold = 32;
/// Whether or not to kick users when they surpass the TilePlace threshold.
[Description("Whether or not to kick users when they surpass the TilePlace threshold.")]
public bool KickOnTilePlaceThresholdBroken = false;
/// Disables a player if this number of liquid sets is exceeded within 1 second.
[Description("Disables a player if this number of liquid sets is exceeded within 1 second.")]
public int TileLiquidThreshold = 50;
/// Whether or not to kick users when they surpass the TileLiquid threshold.
[Description("Whether or not to kick users when they surpass the TileLiquid threshold.")]
public bool KickOnTileLiquidThresholdBroken = false;
/// Whether or not to ignore shrapnel from crystal bullets for the projectile threshold count.
[Description("Whether or not to ignore shrapnel from crystal bullets for the projectile threshold count.")]
public bool ProjIgnoreShrapnel = true;
/// Disable a player if this number of projectiles is created within 1 second.
[Description("Disable a player if this number of projectiles is created within 1 second.")]
public int ProjectileThreshold = 50;
/// Whether or not to kick users when they surpass the Projectile threshold.
[Description("Whether or not to kick users when they surpass the Projectile threshold.")]
public bool KickOnProjectileThresholdBroken = false;
/// Disables a player if this number of HealOtherPlayer packets is sent within 1 second.
[Description("Disables a player if this number of HealOtherPlayer packets is sent within 1 second.")]
public int HealOtherThreshold = 50;
/// Whether or not to kick users when they surpass the HealOther threshold.
[Description("Whether or not to kick users when they surpass the HealOther threshold.")]
public bool KickOnHealOtherThresholdBroken = false;
/// Disables a player if this number of tiles is present in a Tile Rectangle packet
[Description("Disables a player if this number of tiles is present in a Tile Rectangle packet")]
public int TileRectangleSizeThreshold = 50;
/// Whether or not to kick users when they surpass the TileRectangleSize threshold.
[Description("Whether or not to kick users when they surpass the TileRectangleSize threshold.")]
public bool KickOnTileRectangleSizeThresholdBroken = false;
/// Whether or not the server should suppress build permission failure warnings from regions, spawn point, or server edit failure.
[Description("Whether or not the server should suppress build permission failure warnings from regions, spawn point, or server edit failure.")]
public bool SuppressPermissionFailureNotices = false;
#endregion
#region Chat Settings
/// Specifies which string starts a command.
/// Note: Will not function properly if the string length is bigger than 1.
[Description("Specifies which string starts a command.\nNote: Will not function properly if the string length is bigger than 1.")]
public string CommandSpecifier = "/";
/// Specifies which string starts a command silently.
/// Note: Will not function properly if the string length is bigger than 1.
[Description("Specifies which string starts a command silently.\nNote: Will not function properly if the string length is bigger than 1.")]
public string CommandSilentSpecifier = ".";
/// Disables sending logs as messages to players with the log permission.
[Description("Disables sending logs as messages to players with the log permission.")]
public bool DisableSpewLogs = true;
/// Prevents OnSecondUpdate checks from writing to the log file.
[Description("Prevents OnSecondUpdate checks from writing to the log file.")]
public bool DisableSecondUpdateLogs = false;
/// The chat color for the superadmin group.
[Description("The chat color for the superadmin group.\n#.#.# = Red/Blue/Green\nMax value: 255")]
public int[] SuperAdminChatRGB = { 255, 255, 255 };
/// The superadmin chat prefix.
[Description("The superadmin chat prefix.")]
public string SuperAdminChatPrefix = "(Super Admin) ";
/// The superadmin chat suffix.
[Description("The superadmin chat suffix.")]
public string SuperAdminChatSuffix = "";
/// Whether or not to announce a player's geographic location on join, based on their IP.
[Description("Whether or not to announce a player's geographic location on join, based on their IP.")]
public bool EnableGeoIP;
/// Displays a player's IP on join to users with the log permission.
[Description("Displays a player's IP on join to users with the log permission.")]
public bool DisplayIPToAdmins;
/// Changes in-game chat format: {0} = Group Name, {1} = Group Prefix, {2} = Player Name, {3} = Group Suffix, {4} = Chat Message.
[Description("Changes in-game chat format: {0} = Group Name, {1} = Group Prefix, {2} = Player Name, {3} = Group Suffix, {4} = Chat Message.")]
public string ChatFormat = "{1}{2}{3}: {4}";
/// Changes the player name when using chat above heads. Starts with a player name wrapped in brackets, as per Terraria's formatting.\nSame formatting as ChatFormat without the message.
[Description("Changes the player name when using chat above heads. Starts with a player name wrapped in brackets, as per Terraria's formatting.\nSame formatting as ChatFormat without the message.")]
public string ChatAboveHeadsFormat = "{2}";
/// Whether or not to display chat messages above players' heads.
[Description("Whether or not to display chat messages above players' heads.")]
public bool EnableChatAboveHeads = false;
/// The RGB values used for the color of broadcast messages.
[Description("The RGB values used for the color of broadcast messages.\n#.#.# = Red/Blue/Green\nMax value: 255")]
public int[] BroadcastRGB = { 127, 255, 212 };
#endregion
#region MySQL Settings
/// The type of database to use when storing data (either "sqlite" or "mysql").
[Description("The type of database to use when storing data (either \"sqlite\" or \"mysql\").")]
public string StorageType = "sqlite";
/// The path of sqlite db.
[Description("The path of sqlite db.")]
public string SqliteDBPath = "tshock.sqlite";
/// The MySQL hostname and port to direct connections to.
[Description("The MySQL hostname and port to direct connections to.")]
public string MySqlHost = "localhost:3306";
/// The database name to connect to when using MySQL as the database type.
[Description("The database name to connect to when using MySQL as the database type.")]
public string MySqlDbName = "";
/// The username used when connecting to a MySQL database.
[Description("The username used when connecting to a MySQL database.")]
public string MySqlUsername = "";
/// The password used when connecting to a MySQL database.
[Description("The password used when connecting to a MySQL database.")]
public string MySqlPassword = "";
/// Whether or not to save logs to the SQL database instead of a text file.
[Description("Whether or not to save logs to the SQL database instead of a text file.\nDefault = false.")]
public bool UseSqlLogs = false;
/// Number of times the SQL log must fail to insert logs before falling back to the text log.
[Description("Number of times the SQL log must fail to insert logs before falling back to the text log.")]
public int RevertToTextLogsOnSqlFailures = 10;
#endregion
#region REST API Settings
/// Enable or disable the REST API.
[Description("Enable or disable the REST API.")]
public bool RestApiEnabled;
/// The port used by the REST API.
[Description("The port used by the REST API.")]
public int RestApiPort = 7878;
/// Whether or not to log REST API connections.
[Description("Whether or not to log REST API connections.")]
public bool LogRest = false;
/// Whether or not to require token authentication to use the public REST API endpoints.
[Description("Whether or not to require token authentication to use the public REST API endpoints.")]
public bool EnableTokenEndpointAuthentication;
/// The maximum REST requests in the bucket before denying requests. Minimum value is 5.
[Description("The maximum REST requests in the bucket before denying requests. Minimum value is 5.")]
public int RESTMaximumRequestsPerInterval = 5;
/// How often in minutes the REST requests bucket is decreased by one. Minimum value is 1 minute.
[Description("How often in minutes the REST requests bucket is decreased by one. Minimum value is 1 minute.")]
public int RESTRequestBucketDecreaseIntervalMinutes = 1;
/// A dictionary of REST tokens that external applications may use to make queries to your server.
[Description("A dictionary of REST tokens that external applications may use to make queries to your server.")]
public Dictionary ApplicationRestTokens = new Dictionary();
#endregion
}
///
/// TShock's configuration file
///
public class TShockConfig : ConfigFile
{
///
/// Upgrades the configuration file from the old format if required, then reads and returns the currently configured
///
///
///
///
public override TShockSettings ConvertJson(string json, out bool incompleteSettings)
{
var settings = FileTools.LoadConfigAndCheckForChanges(json, out incompleteSettings);
Settings = settings;
OnConfigRead?.Invoke(this);
return settings;
}
///
/// Dumps all configuration options to a text file in Markdown format
///
public static void DumpDescriptions()
{
var sb = new StringBuilder();
var defaults = new TShockSettings();
foreach (var field in defaults.GetType().GetFields().OrderBy(f => f.Name))
{
if (field.IsStatic)
continue;
var name = field.Name;
var type = field.FieldType.Name;
var descattr =
field.GetCustomAttributes(false).FirstOrDefault(o => o is DescriptionAttribute) as DescriptionAttribute;
var desc = descattr != null && !string.IsNullOrWhiteSpace(descattr.Description) ? descattr.Description : "None";
var def = field.GetValue(defaults);
sb.AppendLine("{0} ".SFormat(name));
sb.AppendLine("Type: {0} ".SFormat(type));
sb.AppendLine("Description: {0} ".SFormat(desc));
sb.AppendLine("Default: \"{0}\" ".SFormat(def));
sb.AppendLine();
}
File.WriteAllText("ConfigDescriptions.txt", sb.ToString());
}
}
}