Configuration File now adds missing entries thanks to how JSON works and how default values work.
This commit is contained in:
parent
feea5700ac
commit
b7f0112acd
3 changed files with 30 additions and 27 deletions
|
|
@ -30,16 +30,16 @@ namespace TShockAPI
|
||||||
public static int defaultMaxSpawns = 4;
|
public static int defaultMaxSpawns = 4;
|
||||||
public static int defaultSpawnRate = 700;
|
public static int defaultSpawnRate = 700;
|
||||||
public static int serverPort = 7777;
|
public static int serverPort = 7777;
|
||||||
public static bool enableWhitelist;
|
public static bool enableWhitelist = false;
|
||||||
public static bool infiniteInvasion;
|
public static bool infiniteInvasion = false;
|
||||||
public static bool permaPvp;
|
public static bool permaPvp = false;
|
||||||
public static int killCount;
|
public static int killCount;
|
||||||
public static bool kickCheater = true;
|
public static bool kickCheater = true;
|
||||||
public static bool banCheater = true;
|
public static bool banCheater = true;
|
||||||
public static bool kickGriefer = true;
|
public static bool kickGriefer = true;
|
||||||
public static bool banGriefer = true;
|
public static bool banGriefer = true;
|
||||||
public static bool banTnt;
|
public static bool banTnt = true;
|
||||||
public static bool kickTnt;
|
public static bool kickTnt = true;
|
||||||
public static bool banBoom = true;
|
public static bool banBoom = true;
|
||||||
public static bool kickBoom = true;
|
public static bool kickBoom = true;
|
||||||
public static bool spawnProtect = true;
|
public static bool spawnProtect = true;
|
||||||
|
|
@ -92,33 +92,29 @@ namespace TShockAPI
|
||||||
|
|
||||||
public static void WriteJsonConfiguration()
|
public static void WriteJsonConfiguration()
|
||||||
{
|
{
|
||||||
if (!Directory.Exists(FileTools.SaveDir))
|
if (System.IO.File.Exists(FileTools.SaveDir + "config.json"))
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(FileTools.SaveDir);
|
System.IO.File.Delete(FileTools.SaveDir + "config.json");
|
||||||
}
|
|
||||||
if (File.Exists(FileTools.SaveDir + "config.json"))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
FileTools.CreateFile(FileTools.SaveDir + "config.json");
|
FileTools.CreateFile(FileTools.SaveDir + "config.json");
|
||||||
ConfigFile cfg = new ConfigFile();
|
ConfigFile cfg = new ConfigFile();
|
||||||
cfg.InvasionMultiplier = 50;
|
cfg.InvasionMultiplier = invasionMultiplier;
|
||||||
cfg.DefaultMaximumSpawns = 4;
|
cfg.DefaultMaximumSpawns = defaultMaxSpawns;
|
||||||
cfg.DefaultSpawnRate = 700;
|
cfg.DefaultSpawnRate = defaultSpawnRate;
|
||||||
cfg.ServerPort = 7777;
|
cfg.ServerPort = serverPort;
|
||||||
cfg.EnableWhitelist = false;
|
cfg.EnableWhitelist = enableWhitelist;
|
||||||
cfg.InfiniteInvasion = false;
|
cfg.InfiniteInvasion = infiniteInvasion;
|
||||||
cfg.AlwaysPvP = false;
|
cfg.AlwaysPvP = permaPvp;
|
||||||
cfg.KickCheaters = kickCheater;
|
cfg.KickCheaters = kickCheater;
|
||||||
cfg.BanCheaters = banCheater;
|
cfg.BanCheaters = banCheater;
|
||||||
cfg.KickGriefers = kickGriefer;
|
cfg.KickGriefers = kickGriefer;
|
||||||
cfg.BanGriefers = banGriefer;
|
cfg.BanGriefers = banGriefer;
|
||||||
cfg.BanKillTileAbusers = true;
|
cfg.BanKillTileAbusers = banGriefer;
|
||||||
cfg.KickKillTileAbusers = true;
|
cfg.KickKillTileAbusers = kickGriefer;
|
||||||
cfg.BanExplosives = true;
|
cfg.BanExplosives = banBoom;
|
||||||
cfg.KickExplosives = true;
|
cfg.KickExplosives = kickBoom;
|
||||||
cfg.SpawnProtection = true;
|
cfg.SpawnProtection = spawnProtect;
|
||||||
cfg.SpawnProtectionRadius = 5;
|
cfg.SpawnProtectionRadius = spawnProtectRadius;
|
||||||
cfg.MaxSlots = maxSlots;
|
cfg.MaxSlots = maxSlots;
|
||||||
cfg.RangeChecks = rangeChecks;
|
cfg.RangeChecks = rangeChecks;
|
||||||
cfg.SpamChecks = spamChecks;
|
cfg.SpamChecks = spamChecks;
|
||||||
|
|
|
||||||
|
|
@ -92,8 +92,15 @@ namespace TShockAPI
|
||||||
sw.Write(Resources.users);
|
sw.Write(Resources.users);
|
||||||
sw.Close();
|
sw.Close();
|
||||||
}
|
}
|
||||||
|
if (File.Exists(FileTools.SaveDir + "config.json"))
|
||||||
|
{
|
||||||
|
ConfigurationManager.ReadJsonConfiguration();
|
||||||
|
} else
|
||||||
|
{
|
||||||
ConfigurationManager.WriteJsonConfiguration();
|
ConfigurationManager.WriteJsonConfiguration();
|
||||||
ConfigurationManager.ReadJsonConfiguration();
|
ConfigurationManager.ReadJsonConfiguration();
|
||||||
|
}
|
||||||
|
|
||||||
Netplay.serverPort = ConfigurationManager.serverPort;
|
Netplay.serverPort = ConfigurationManager.serverPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -206,7 +206,7 @@ namespace TShockAPI
|
||||||
public override void DeInitialize()
|
public override void DeInitialize()
|
||||||
{
|
{
|
||||||
Bans.SaveBans();
|
Bans.SaveBans();
|
||||||
|
ConfigurationManager.WriteJsonConfiguration();
|
||||||
GameHooks.PostInitialize -= OnPostInit;
|
GameHooks.PostInitialize -= OnPostInit;
|
||||||
GameHooks.Update -= OnUpdate;
|
GameHooks.Update -= OnUpdate;
|
||||||
ServerHooks.Chat -= OnChat;
|
ServerHooks.Chat -= OnChat;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue