Force time config.

This commit is contained in:
Zidonuke 2011-12-27 10:06:34 -05:00
parent 054fc79f91
commit 9a4a77dfcc
2 changed files with 38 additions and 18 deletions

View file

@ -186,6 +186,9 @@ namespace TShockAPI
[Description("Change ingame chat format, {0} = Group Name, {1} = Group Prefix, {2} = Player Name, {3} = Group Suffix, {4} = Chat Message")]
public string ChatFormat = "{1}{2}{3}: {4}";
[Description("Force the world time to be normal, day, or night")]
public string ForceTime = "normal";
public static ConfigFile Read(string path)
{
if (!File.Exists(path))

View file

@ -431,7 +431,25 @@ namespace TShockAPI
//call these every second, not every update
if ((DateTime.UtcNow - LastCheck).TotalSeconds >= 1)
{
OnSecondUpdate();
LastCheck = DateTime.UtcNow;
}
}
private void OnSecondUpdate()
{
if (Config.ForceTime != "normal")
{
switch(Config.ForceTime)
{
case "day":
TSPlayer.Server.SetTime(true, 27000.0);
break;
case "night":
TSPlayer.Server.SetTime(false, 16200.0);
break;
}
}
int count = 0;
foreach (TSPlayer player in Players)
{
@ -459,7 +477,6 @@ namespace TShockAPI
}
Console.Title = string.Format("TerrariaShock Version {0} ({1}) ({2}/{3})", Version, VersionCodename, count, Config.MaxSlots);
}
}
private void OnJoin(int ply, HandledEventArgs handler)
{