Renamed settings to start with a Capital letter

Removed config read on post init. Already read in SetupConfig which is called in Init
Added option to disable auto saving
This commit is contained in:
high 2011-06-25 00:44:07 -04:00
parent d369852998
commit 17cd6652d7
7 changed files with 48 additions and 30 deletions

View file

@ -873,8 +873,8 @@ namespace TShockAPI
private static void SetSpawn(CommandArgs args)
{
ConfigurationManager.spawnTileX = args.Player.TileX;
ConfigurationManager.spawnTileY = args.Player.TileY + 3;
ConfigurationManager.SpawnTileX = args.Player.TileX;
ConfigurationManager.SpawnTileY = args.Player.TileY + 3;
ConfigurationManager.Spawn_WorldID = Main.worldID;
ConfigurationManager.WriteJsonConfiguration();
args.Player.SendMessage("Set server spawn point to your position");
@ -882,8 +882,8 @@ namespace TShockAPI
private static void SaveSpawn(CommandArgs args)
{
Main.spawnTileX = ConfigurationManager.spawnTileX;
Main.spawnTileY = ConfigurationManager.spawnTileY;
Main.spawnTileX = ConfigurationManager.SpawnTileX;
Main.spawnTileY = ConfigurationManager.SpawnTileY;
WorldGen.saveWorld();
args.Player.SendMessage("Saved current spawn point to file.");
}

View file

@ -54,8 +54,8 @@ namespace TShockAPI
public bool ListServer = false;
public int spawnTileX;
public int spawnTileY;
public int SpawnTileX;
public int SpawnTileY;
public int Spawn_WorldID;
public bool RememberLeavePos = false;
@ -63,5 +63,7 @@ namespace TShockAPI
public bool HardcoreOnly = false;
public bool KickOnHardcoreOnlyDeath = false;
public bool BanOnHardcoreOnlyDeath = false;
public bool AutoSave = true;
}
}

View file

@ -78,15 +78,17 @@ namespace TShockAPI
public static bool ListServer = false;
public static int Spawn_WorldID;
public static int originalSpawnX;
public static int originalSpawnY;
public static int spawnTileX;
public static int spawnTileY;
public static int OriginalSpawnX;
public static int OriginalSpawnY;
public static int SpawnTileX;
public static int SpawnTileY;
public static bool hardcoreOnly = false;
public static bool HardcoreOnly = false;
public static bool KickOnHardcoreDeath = false;
public static bool BanOnHardcoreDeath = false;
public static bool AutoSave = true;
public static void ReadJsonConfiguration()
{
TextReader tr = new StreamReader(FileTools.ConfigPath);
@ -125,15 +127,16 @@ namespace TShockAPI
BackupInterval = cfg.BackupInterval;
BackupKeepFor = cfg.BackupKeepFor;
ListServer = cfg.ListServer;
originalSpawnX = Main.spawnTileX;
originalSpawnY = Main.spawnTileY;
spawnTileX = cfg.spawnTileX;
spawnTileY = cfg.spawnTileY;
OriginalSpawnX = Main.spawnTileX;
OriginalSpawnY = Main.spawnTileY;
SpawnTileX = cfg.SpawnTileX;
SpawnTileY = cfg.SpawnTileY;
Spawn_WorldID = cfg.Spawn_WorldID;
RememberLeavePos = cfg.RememberLeavePos;
hardcoreOnly = cfg.HardcoreOnly;
HardcoreOnly = cfg.HardcoreOnly;
KickOnHardcoreDeath = cfg.KickOnHardcoreOnlyDeath;
BanOnHardcoreDeath = cfg.BanOnHardcoreOnlyDeath;
AutoSave = cfg.AutoSave;
}
public static void WriteJsonConfiguration()
@ -168,13 +171,14 @@ namespace TShockAPI
cfg.BackupInterval = BackupInterval;
cfg.BackupKeepFor = BackupKeepFor;
cfg.ListServer = ListServer;
cfg.spawnTileX = spawnTileX;
cfg.spawnTileY = spawnTileY;
cfg.SpawnTileX = SpawnTileX;
cfg.SpawnTileY = SpawnTileY;
cfg.RememberLeavePos = RememberLeavePos;
cfg.Spawn_WorldID = Spawn_WorldID;
cfg.HardcoreOnly = hardcoreOnly;
cfg.HardcoreOnly = HardcoreOnly;
cfg.BanOnHardcoreOnlyDeath = BanOnHardcoreDeath;
cfg.KickOnHardcoreOnlyDeath = KickOnHardcoreDeath;
cfg.AutoSave = AutoSave;
string json = JsonConvert.SerializeObject(cfg, Formatting.Indented);
TextWriter tr = new StreamWriter(FileTools.ConfigPath);
tr.Write(json);

View file

@ -164,7 +164,7 @@ namespace TShockAPI
{
return Tools.HandleGriefer(args.Player, "Sent client info more than once");
}
if (ConfigurationManager.hardcoreOnly)
if (ConfigurationManager.HardcoreOnly)
if (!hardcore)
{
Tools.ForceKick(args.Player, "Server is set to hardcore characters only!");
@ -459,7 +459,7 @@ namespace TShockAPI
if (args.Player.InitSpawn)
{
if (ConfigurationManager.hardcoreOnly && (ConfigurationManager.KickOnHardcoreDeath || ConfigurationManager.BanOnHardcoreDeath))
if (ConfigurationManager.HardcoreOnly && (ConfigurationManager.KickOnHardcoreDeath || ConfigurationManager.BanOnHardcoreDeath))
if (args.TPlayer.selectedItem != 50)
{
if (ConfigurationManager.BanOnHardcoreDeath)

View file

@ -98,6 +98,16 @@ namespace TShockAPI
Write(message, LogLevel.Info);
}
/// <summary>
/// Writes an informative string to the log file. Also outputs to the console.
/// </summary>
/// <param name="message">The message to be written.</param>
public static void ConsoleInfo(String message)
{
Console.WriteLine(message);
Write(message, LogLevel.Info);
}
/// <summary>
/// Writes a debug string to the log file.
/// </summary>

View file

@ -35,5 +35,5 @@ using System.Runtime.InteropServices;
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.3.0.0624")]
[assembly: AssemblyFileVersion("2.3.0.0624")]
[assembly: AssemblyVersion("2.3.0.0625")]
[assembly: AssemblyFileVersion("2.3.0.0625")]

View file

@ -34,7 +34,7 @@ namespace TShockAPI
[APIVersion(1, 5)]
public class TShock : TerrariaPlugin
{
public static readonly Version VersionNum = Assembly.GetExecutingAssembly().GetName().Version;
public static readonly Version VersionNum = Assembly.GetExecutingAssembly().GetName().Version;
public static readonly string VersionCodename = "Lol, packet changes.";
public static readonly string SavePath = "tshock";
@ -107,10 +107,13 @@ namespace TShockAPI
ItemManager.LoadBans();
Main.autoSave = ConfigurationManager.AutoSave;
Backups.KeepFor = ConfigurationManager.BackupKeepFor;
Backups.Interval = ConfigurationManager.BackupInterval;
Log.ConsoleInfo("AutoSave " + (ConfigurationManager.AutoSave ? "Enabled" : "Disabled"));
Log.ConsoleInfo("Backups " + (Backups.Interval > 0 ? "Enabled" : "Disabled"));
HandleCommandLine(Environment.GetCommandLineArgs());
}
@ -183,7 +186,6 @@ namespace TShockAPI
Console.WriteLine("This token will only display ONCE. This only works ONCE. If you don't use it and the server goes down, delete auth.lck.");
FileTools.CreateFile(Path.Combine(SavePath, "auth.lck"));
}
ConfigurationManager.ReadJsonConfiguration();
}
private void OnUpdate(GameTime time)
@ -232,10 +234,10 @@ namespace TShockAPI
var id = Main.worldID;
if (ConfigurationManager.Spawn_WorldID != Main.worldID)
{
Main.spawnTileX = ConfigurationManager.originalSpawnX;
Main.spawnTileY = ConfigurationManager.originalSpawnY;
ConfigurationManager.spawnTileX = Main.spawnTileX;
ConfigurationManager.spawnTileY = Main.spawnTileY;
Main.spawnTileX = ConfigurationManager.OriginalSpawnX;
Main.spawnTileY = ConfigurationManager.OriginalSpawnY;
ConfigurationManager.SpawnTileX = Main.spawnTileX;
ConfigurationManager.SpawnTileY = Main.spawnTileY;
ConfigurationManager.Spawn_WorldID = Main.worldID;
}
}