Send WorldInfo when setting various time flags, fix time format

This commit is contained in:
MarioE 2014-06-30 11:02:36 -04:00
parent 97252dfe93
commit e715a6bac9
2 changed files with 52 additions and 26 deletions

View file

@ -1560,20 +1560,20 @@ namespace TShockAPI
private static void Fullmoon(CommandArgs args) private static void Fullmoon(CommandArgs args)
{ {
TSPlayer.Server.SetFullMoon(true); TSPlayer.Server.SetFullMoon();
TShock.Utils.Broadcast(string.Format("{0} turned on the full moon.", args.Player.Name), Color.Green); TSPlayer.All.SendInfoMessage("{0} started a full moon.", args.Player.Name);
} }
private static void Bloodmoon(CommandArgs args) private static void Bloodmoon(CommandArgs args)
{ {
TSPlayer.Server.SetBloodMoon(true); TSPlayer.Server.SetBloodMoon(!Main.bloodMoon);
TShock.Utils.Broadcast(string.Format("{0} turned on the blood moon.", args.Player.Name), Color.Green); TSPlayer.All.SendInfoMessage("{0} {1}ed a blood moon.", args.Player.Name, Main.bloodMoon ? "start" : "stopp");
} }
private static void Eclipse(CommandArgs args) private static void Eclipse(CommandArgs args)
{ {
TSPlayer.Server.SetEclipse(true); TSPlayer.Server.SetEclipse(!Main.eclipse);
TShock.Utils.Broadcast(string.Format("{0} has forced an Eclipse!", args.Player.Name), Color.Green); TSPlayer.All.SendInfoMessage("{0} {1}ed an eclipse.", args.Player.Name, Main.eclipse ? "start" : "stopp");
} }
private static void Invade(CommandArgs args) private static void Invade(CommandArgs args)
@ -1616,8 +1616,6 @@ namespace TShockAPI
private static void PumpkinMoon(CommandArgs args) private static void PumpkinMoon(CommandArgs args)
{ {
TSPlayer.Server.SetPumpkinMoon(true);
int wave = 1; int wave = 1;
if (args.Parameters.Count != 0) if (args.Parameters.Count != 0)
{ {
@ -1628,6 +1626,7 @@ namespace TShockAPI
} }
} }
TSPlayer.Server.SetPumpkinMoon(true);
Main.bloodMoon = false; Main.bloodMoon = false;
NPC.waveKills = 0f; NPC.waveKills = 0f;
NPC.waveCount = wave; NPC.waveCount = wave;
@ -1636,8 +1635,6 @@ namespace TShockAPI
private static void FrostMoon(CommandArgs args) private static void FrostMoon(CommandArgs args)
{ {
TSPlayer.Server.SetFrostMoon(true);
int wave = 1; int wave = 1;
if (args.Parameters.Count != 0) if (args.Parameters.Count != 0)
{ {
@ -1648,6 +1645,7 @@ namespace TShockAPI
} }
} }
TSPlayer.Server.SetFrostMoon(true);
Main.bloodMoon = false; Main.bloodMoon = false;
NPC.waveKills = 0f; NPC.waveKills = 0f;
NPC.waveCount = wave; NPC.waveCount = wave;
@ -3093,7 +3091,7 @@ namespace TShockAPI
time += 4.5; time += 4.5;
if (!Main.dayTime) if (!Main.dayTime)
time += 15.0; time += 15.0;
args.Player.SendInfoMessage("The current time is {0:D2}:{1:D2}.", (int)Math.Floor(time), (int)Math.Round((time % 1.0) * 30.0)); args.Player.SendInfoMessage("The current time is {0}:{1:D2}.", (int)Math.Floor(time), (int)Math.Round((time % 1.0) * 30.0));
return; return;
} }
@ -3140,7 +3138,7 @@ namespace TShockAPI
TSPlayer.Server.SetTime(false, (double)((time - 15.00m) * 3600.0m)); TSPlayer.Server.SetTime(false, (double)((time - 15.00m) * 3600.0m));
else else
TSPlayer.Server.SetTime(true, (double)(time * 3600.0m)); TSPlayer.Server.SetTime(true, (double)(time * 3600.0m));
TSPlayer.All.SendInfoMessage("{0} set the time to {1:D2}:{2:D2}.", args.Player.Name, hours, minutes); TSPlayer.All.SendInfoMessage("{0} set the time to {1}:{2:D2}.", args.Player.Name, hours, minutes);
break; break;
} }
} }

View file

@ -1020,42 +1020,70 @@ namespace TShockAPI
//RconHandler.Response += msg + "\n"; //RconHandler.Response += msg + "\n";
} }
public void SetFullMoon(bool fullmoon) public void SetFullMoon()
{ {
Main.dayTime = false;
Main.moonPhase = 0; Main.moonPhase = 0;
SetTime(false, 0); Main.time = 0.0;
TSPlayer.All.SendData(PacketTypes.WorldInfo);
} }
public void SetBloodMoon(bool bloodMoon) public void SetBloodMoon(bool bloodMoon)
{ {
Main.bloodMoon = bloodMoon; if (bloodMoon)
SetTime(false, 0); {
Main.dayTime = false;
Main.bloodMoon = true;
Main.time = 0.0;
}
else
Main.bloodMoon = false;
TSPlayer.All.SendData(PacketTypes.WorldInfo);
} }
public void SetFrostMoon(bool frostMoon) public void SetFrostMoon(bool snowMoon)
{ {
Main.snowMoon = frostMoon; if (snowMoon)
SetTime(false, 0); {
Main.dayTime = false;
Main.snowMoon = true;
Main.time = 0.0;
}
else
Main.snowMoon = false;
TSPlayer.All.SendData(PacketTypes.WorldInfo);
} }
public void SetPumpkinMoon(bool pumpkinMoon) public void SetPumpkinMoon(bool pumpkinMoon)
{ {
Main.pumpkinMoon = pumpkinMoon; if (pumpkinMoon)
SetTime(false, 0); {
Main.dayTime = false;
Main.pumpkinMoon = true;
Main.time = 0.0;
}
else
Main.pumpkinMoon = false;
TSPlayer.All.SendData(PacketTypes.WorldInfo);
} }
public void SetEclipse(bool Eclipse) public void SetEclipse(bool eclipse)
{ {
Main.eclipse = Eclipse; if (eclipse)
SetTime(true, 150); {
Main.dayTime = Main.eclipse = true;
Main.time = 0.0;
}
else
Main.eclipse = false;
TSPlayer.All.SendData(PacketTypes.WorldInfo);
} }
public void SetTime(bool dayTime, double time) public void SetTime(bool dayTime, double time)
{ {
Main.dayTime = dayTime; Main.dayTime = dayTime;
Main.time = time; Main.time = time;
NetMessage.SendData((int) PacketTypes.TimeSet, -1, -1, "", 0, 0, Main.sunModY, Main.moonModY); TSPlayer.All.SendData(PacketTypes.TimeSet, "", 0, 0, Main.sunModY, Main.moonModY);
// NetMessage.syncPlayers(); Is not in any way resposnsible for time...
} }
public void SpawnNPC(int type, string name, int amount, int startTileX, int startTileY, int tileXRange = 100, public void SpawnNPC(int type, string name, int amount, int startTileX, int startTileY, int tileXRange = 100,