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

@ -185,6 +185,9 @@ namespace TShockAPI
[Description("Change ingame chat format, {0} = Group Name, {1} = Group Prefix, {2} = Player Name, {3} = Group Suffix, {4} = Chat Message")] [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}"; 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) public static ConfigFile Read(string path)
{ {

View file

@ -431,34 +431,51 @@ namespace TShockAPI
//call these every second, not every update //call these every second, not every update
if ((DateTime.UtcNow - LastCheck).TotalSeconds >= 1) if ((DateTime.UtcNow - LastCheck).TotalSeconds >= 1)
{ {
OnSecondUpdate();
LastCheck = DateTime.UtcNow; LastCheck = DateTime.UtcNow;
int count = 0; }
foreach (TSPlayer player in Players) }
private void OnSecondUpdate()
{
if (Config.ForceTime != "normal")
{
switch(Config.ForceTime)
{ {
if (player != null && player.Active) 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)
{
if (player != null && player.Active)
{
count++;
if (player.TilesDestroyed != null)
{ {
count++; if (player.TileThreshold >= Config.TileThreshold)
if (player.TilesDestroyed != null)
{ {
if (player.TileThreshold >= Config.TileThreshold) TSPlayer.Server.RevertKillTile(player.TilesDestroyed);
{
TSPlayer.Server.RevertKillTile(player.TilesDestroyed);
}
if (player.TileThreshold > 0)
{
player.TileThreshold = 0;
player.TilesDestroyed.Clear();
}
} }
if (player.ForceSpawn && (DateTime.Now - player.LastDeath).Seconds >= 3) if (player.TileThreshold > 0)
{ {
player.Spawn(); player.TileThreshold = 0;
player.ForceSpawn = false; player.TilesDestroyed.Clear();
} }
} }
if (player.ForceSpawn && (DateTime.Now - player.LastDeath).Seconds >= 3)
{
player.Spawn();
player.ForceSpawn = false;
}
} }
Console.Title = string.Format("TerrariaShock Version {0} ({1}) ({2}/{3})", Version, VersionCodename, count, Config.MaxSlots);
} }
Console.Title = string.Format("TerrariaShock Version {0} ({1}) ({2}/{3})", Version, VersionCodename, count, Config.MaxSlots);
} }
private void OnJoin(int ply, HandledEventArgs handler) private void OnJoin(int ply, HandledEventArgs handler)