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:
parent
d369852998
commit
17cd6652d7
7 changed files with 48 additions and 30 deletions
|
|
@ -873,8 +873,8 @@ namespace TShockAPI
|
||||||
|
|
||||||
private static void SetSpawn(CommandArgs args)
|
private static void SetSpawn(CommandArgs args)
|
||||||
{
|
{
|
||||||
ConfigurationManager.spawnTileX = args.Player.TileX;
|
ConfigurationManager.SpawnTileX = args.Player.TileX;
|
||||||
ConfigurationManager.spawnTileY = args.Player.TileY + 3;
|
ConfigurationManager.SpawnTileY = args.Player.TileY + 3;
|
||||||
ConfigurationManager.Spawn_WorldID = Main.worldID;
|
ConfigurationManager.Spawn_WorldID = Main.worldID;
|
||||||
ConfigurationManager.WriteJsonConfiguration();
|
ConfigurationManager.WriteJsonConfiguration();
|
||||||
args.Player.SendMessage("Set server spawn point to your position");
|
args.Player.SendMessage("Set server spawn point to your position");
|
||||||
|
|
@ -882,8 +882,8 @@ namespace TShockAPI
|
||||||
|
|
||||||
private static void SaveSpawn(CommandArgs args)
|
private static void SaveSpawn(CommandArgs args)
|
||||||
{
|
{
|
||||||
Main.spawnTileX = ConfigurationManager.spawnTileX;
|
Main.spawnTileX = ConfigurationManager.SpawnTileX;
|
||||||
Main.spawnTileY = ConfigurationManager.spawnTileY;
|
Main.spawnTileY = ConfigurationManager.SpawnTileY;
|
||||||
WorldGen.saveWorld();
|
WorldGen.saveWorld();
|
||||||
args.Player.SendMessage("Saved current spawn point to file.");
|
args.Player.SendMessage("Saved current spawn point to file.");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,8 +54,8 @@ namespace TShockAPI
|
||||||
|
|
||||||
public bool ListServer = false;
|
public bool ListServer = false;
|
||||||
|
|
||||||
public int spawnTileX;
|
public int SpawnTileX;
|
||||||
public int spawnTileY;
|
public int SpawnTileY;
|
||||||
public int Spawn_WorldID;
|
public int Spawn_WorldID;
|
||||||
|
|
||||||
public bool RememberLeavePos = false;
|
public bool RememberLeavePos = false;
|
||||||
|
|
@ -63,5 +63,7 @@ namespace TShockAPI
|
||||||
public bool HardcoreOnly = false;
|
public bool HardcoreOnly = false;
|
||||||
public bool KickOnHardcoreOnlyDeath = false;
|
public bool KickOnHardcoreOnlyDeath = false;
|
||||||
public bool BanOnHardcoreOnlyDeath = false;
|
public bool BanOnHardcoreOnlyDeath = false;
|
||||||
|
|
||||||
|
public bool AutoSave = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -78,15 +78,17 @@ namespace TShockAPI
|
||||||
public static bool ListServer = false;
|
public static bool ListServer = false;
|
||||||
|
|
||||||
public static int Spawn_WorldID;
|
public static int Spawn_WorldID;
|
||||||
public static int originalSpawnX;
|
public static int OriginalSpawnX;
|
||||||
public static int originalSpawnY;
|
public static int OriginalSpawnY;
|
||||||
public static int spawnTileX;
|
public static int SpawnTileX;
|
||||||
public static int spawnTileY;
|
public static int SpawnTileY;
|
||||||
|
|
||||||
public static bool hardcoreOnly = false;
|
public static bool HardcoreOnly = false;
|
||||||
public static bool KickOnHardcoreDeath = false;
|
public static bool KickOnHardcoreDeath = false;
|
||||||
public static bool BanOnHardcoreDeath = false;
|
public static bool BanOnHardcoreDeath = false;
|
||||||
|
|
||||||
|
public static bool AutoSave = true;
|
||||||
|
|
||||||
public static void ReadJsonConfiguration()
|
public static void ReadJsonConfiguration()
|
||||||
{
|
{
|
||||||
TextReader tr = new StreamReader(FileTools.ConfigPath);
|
TextReader tr = new StreamReader(FileTools.ConfigPath);
|
||||||
|
|
@ -125,15 +127,16 @@ namespace TShockAPI
|
||||||
BackupInterval = cfg.BackupInterval;
|
BackupInterval = cfg.BackupInterval;
|
||||||
BackupKeepFor = cfg.BackupKeepFor;
|
BackupKeepFor = cfg.BackupKeepFor;
|
||||||
ListServer = cfg.ListServer;
|
ListServer = cfg.ListServer;
|
||||||
originalSpawnX = Main.spawnTileX;
|
OriginalSpawnX = Main.spawnTileX;
|
||||||
originalSpawnY = Main.spawnTileY;
|
OriginalSpawnY = Main.spawnTileY;
|
||||||
spawnTileX = cfg.spawnTileX;
|
SpawnTileX = cfg.SpawnTileX;
|
||||||
spawnTileY = cfg.spawnTileY;
|
SpawnTileY = cfg.SpawnTileY;
|
||||||
Spawn_WorldID = cfg.Spawn_WorldID;
|
Spawn_WorldID = cfg.Spawn_WorldID;
|
||||||
RememberLeavePos = cfg.RememberLeavePos;
|
RememberLeavePos = cfg.RememberLeavePos;
|
||||||
hardcoreOnly = cfg.HardcoreOnly;
|
HardcoreOnly = cfg.HardcoreOnly;
|
||||||
KickOnHardcoreDeath = cfg.KickOnHardcoreOnlyDeath;
|
KickOnHardcoreDeath = cfg.KickOnHardcoreOnlyDeath;
|
||||||
BanOnHardcoreDeath = cfg.BanOnHardcoreOnlyDeath;
|
BanOnHardcoreDeath = cfg.BanOnHardcoreOnlyDeath;
|
||||||
|
AutoSave = cfg.AutoSave;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void WriteJsonConfiguration()
|
public static void WriteJsonConfiguration()
|
||||||
|
|
@ -168,13 +171,14 @@ namespace TShockAPI
|
||||||
cfg.BackupInterval = BackupInterval;
|
cfg.BackupInterval = BackupInterval;
|
||||||
cfg.BackupKeepFor = BackupKeepFor;
|
cfg.BackupKeepFor = BackupKeepFor;
|
||||||
cfg.ListServer = ListServer;
|
cfg.ListServer = ListServer;
|
||||||
cfg.spawnTileX = spawnTileX;
|
cfg.SpawnTileX = SpawnTileX;
|
||||||
cfg.spawnTileY = spawnTileY;
|
cfg.SpawnTileY = SpawnTileY;
|
||||||
cfg.RememberLeavePos = RememberLeavePos;
|
cfg.RememberLeavePos = RememberLeavePos;
|
||||||
cfg.Spawn_WorldID = Spawn_WorldID;
|
cfg.Spawn_WorldID = Spawn_WorldID;
|
||||||
cfg.HardcoreOnly = hardcoreOnly;
|
cfg.HardcoreOnly = HardcoreOnly;
|
||||||
cfg.BanOnHardcoreOnlyDeath = BanOnHardcoreDeath;
|
cfg.BanOnHardcoreOnlyDeath = BanOnHardcoreDeath;
|
||||||
cfg.KickOnHardcoreOnlyDeath = KickOnHardcoreDeath;
|
cfg.KickOnHardcoreOnlyDeath = KickOnHardcoreDeath;
|
||||||
|
cfg.AutoSave = AutoSave;
|
||||||
string json = JsonConvert.SerializeObject(cfg, Formatting.Indented);
|
string json = JsonConvert.SerializeObject(cfg, Formatting.Indented);
|
||||||
TextWriter tr = new StreamWriter(FileTools.ConfigPath);
|
TextWriter tr = new StreamWriter(FileTools.ConfigPath);
|
||||||
tr.Write(json);
|
tr.Write(json);
|
||||||
|
|
|
||||||
|
|
@ -164,7 +164,7 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
return Tools.HandleGriefer(args.Player, "Sent client info more than once");
|
return Tools.HandleGriefer(args.Player, "Sent client info more than once");
|
||||||
}
|
}
|
||||||
if (ConfigurationManager.hardcoreOnly)
|
if (ConfigurationManager.HardcoreOnly)
|
||||||
if (!hardcore)
|
if (!hardcore)
|
||||||
{
|
{
|
||||||
Tools.ForceKick(args.Player, "Server is set to hardcore characters only!");
|
Tools.ForceKick(args.Player, "Server is set to hardcore characters only!");
|
||||||
|
|
@ -459,7 +459,7 @@ namespace TShockAPI
|
||||||
|
|
||||||
if (args.Player.InitSpawn)
|
if (args.Player.InitSpawn)
|
||||||
{
|
{
|
||||||
if (ConfigurationManager.hardcoreOnly && (ConfigurationManager.KickOnHardcoreDeath || ConfigurationManager.BanOnHardcoreDeath))
|
if (ConfigurationManager.HardcoreOnly && (ConfigurationManager.KickOnHardcoreDeath || ConfigurationManager.BanOnHardcoreDeath))
|
||||||
if (args.TPlayer.selectedItem != 50)
|
if (args.TPlayer.selectedItem != 50)
|
||||||
{
|
{
|
||||||
if (ConfigurationManager.BanOnHardcoreDeath)
|
if (ConfigurationManager.BanOnHardcoreDeath)
|
||||||
|
|
|
||||||
|
|
@ -98,6 +98,16 @@ namespace TShockAPI
|
||||||
Write(message, LogLevel.Info);
|
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>
|
/// <summary>
|
||||||
/// Writes a debug string to the log file.
|
/// Writes a debug string to the log file.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -35,5 +35,5 @@ using System.Runtime.InteropServices;
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
|
||||||
[assembly: AssemblyVersion("2.3.0.0624")]
|
[assembly: AssemblyVersion("2.3.0.0625")]
|
||||||
[assembly: AssemblyFileVersion("2.3.0.0624")]
|
[assembly: AssemblyFileVersion("2.3.0.0625")]
|
||||||
|
|
@ -34,7 +34,7 @@ namespace TShockAPI
|
||||||
[APIVersion(1, 5)]
|
[APIVersion(1, 5)]
|
||||||
public class TShock : TerrariaPlugin
|
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 VersionCodename = "Lol, packet changes.";
|
||||||
|
|
||||||
public static readonly string SavePath = "tshock";
|
public static readonly string SavePath = "tshock";
|
||||||
|
|
@ -107,10 +107,13 @@ namespace TShockAPI
|
||||||
ItemManager.LoadBans();
|
ItemManager.LoadBans();
|
||||||
|
|
||||||
|
|
||||||
|
Main.autoSave = ConfigurationManager.AutoSave;
|
||||||
Backups.KeepFor = ConfigurationManager.BackupKeepFor;
|
Backups.KeepFor = ConfigurationManager.BackupKeepFor;
|
||||||
Backups.Interval = ConfigurationManager.BackupInterval;
|
Backups.Interval = ConfigurationManager.BackupInterval;
|
||||||
|
|
||||||
|
Log.ConsoleInfo("AutoSave " + (ConfigurationManager.AutoSave ? "Enabled" : "Disabled"));
|
||||||
|
Log.ConsoleInfo("Backups " + (Backups.Interval > 0 ? "Enabled" : "Disabled"));
|
||||||
|
|
||||||
HandleCommandLine(Environment.GetCommandLineArgs());
|
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.");
|
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"));
|
FileTools.CreateFile(Path.Combine(SavePath, "auth.lck"));
|
||||||
}
|
}
|
||||||
ConfigurationManager.ReadJsonConfiguration();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnUpdate(GameTime time)
|
private void OnUpdate(GameTime time)
|
||||||
|
|
@ -232,10 +234,10 @@ namespace TShockAPI
|
||||||
var id = Main.worldID;
|
var id = Main.worldID;
|
||||||
if (ConfigurationManager.Spawn_WorldID != Main.worldID)
|
if (ConfigurationManager.Spawn_WorldID != Main.worldID)
|
||||||
{
|
{
|
||||||
Main.spawnTileX = ConfigurationManager.originalSpawnX;
|
Main.spawnTileX = ConfigurationManager.OriginalSpawnX;
|
||||||
Main.spawnTileY = ConfigurationManager.originalSpawnY;
|
Main.spawnTileY = ConfigurationManager.OriginalSpawnY;
|
||||||
ConfigurationManager.spawnTileX = Main.spawnTileX;
|
ConfigurationManager.SpawnTileX = Main.spawnTileX;
|
||||||
ConfigurationManager.spawnTileY = Main.spawnTileY;
|
ConfigurationManager.SpawnTileY = Main.spawnTileY;
|
||||||
ConfigurationManager.Spawn_WorldID = Main.worldID;
|
ConfigurationManager.Spawn_WorldID = Main.worldID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue