From ff815aa2fc23d6d14a7c5df79b71ad662aad2c0b Mon Sep 17 00:00:00 2001 From: Robin Kanters Date: Fri, 8 May 2015 21:48:03 +0200 Subject: [PATCH] /time is no longer a debug command, deserves its own file --- TrueCraft/Commands/DebugCommands.cs | 59 +--------------------------- TrueCraft/Commands/TimeCommand.cs | 60 +++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 57 deletions(-) create mode 100644 TrueCraft/Commands/TimeCommand.cs diff --git a/TrueCraft/Commands/DebugCommands.cs b/TrueCraft/Commands/DebugCommands.cs index a33976e..55af1aa 100644 --- a/TrueCraft/Commands/DebugCommands.cs +++ b/TrueCraft/Commands/DebugCommands.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; +using System.Collections.Generic; using System.Text; using TrueCraft.Core.Windows; using TrueCraft.API; @@ -74,60 +72,7 @@ namespace TrueCraft.Commands client.SendMessage("/pos: Toggles client logging."); } } - - public class TimeCommand : Command - { - public override string Name - { - get { return "time"; } - } - - public override string Description - { - get { return "Shows the current time."; } - } - - public override string[] Aliases - { - get { return new string[0]; } - } - - public override void Handle(IRemoteClient Client, string alias, string[] arguments) - { - switch (arguments.Length) - { - case 0: - Client.SendMessage(Client.World.Time.ToString()); - break; - case 2: - if (!arguments[0].Equals("set")) - Help(Client, alias, arguments); - - int newTime; - - if(!Int32.TryParse(arguments[1], out newTime)) - Help(Client, alias, arguments); - - Client.World.Time = newTime; - - Client.SendMessage(string.Format("Setting time to {0}", arguments[1])); - - foreach (var client in Client.Server.Clients.Where(c => c.World.Equals(Client.World))) - client.QueuePacket(new TimeUpdatePacket(newTime)); - - break; - default: - Help(Client, alias, arguments); - break; - } - } - - public override void Help(IRemoteClient client, string alias, string[] arguments) - { - client.SendMessage("/time: Shows the current time."); - } - } - + public class ResendInvCommand : Command { public override string Name diff --git a/TrueCraft/Commands/TimeCommand.cs b/TrueCraft/Commands/TimeCommand.cs new file mode 100644 index 0000000..5c73135 --- /dev/null +++ b/TrueCraft/Commands/TimeCommand.cs @@ -0,0 +1,60 @@ +using System; +using System.Linq; +using TrueCraft.API.Networking; +using TrueCraft.Core.Networking.Packets; + +namespace TrueCraft.Commands +{ + public class TimeCommand : Command + { + public override string Name + { + get { return "time"; } + } + + public override string Description + { + get { return "Shows the current time."; } + } + + public override string[] Aliases + { + get { return new string[0]; } + } + + public override void Handle(IRemoteClient Client, string alias, string[] arguments) + { + switch (arguments.Length) + { + case 0: + Client.SendMessage(Client.World.Time.ToString()); + break; + case 2: + if (!arguments[0].Equals("set")) + Help(Client, alias, arguments); + + int newTime; + + if(!Int32.TryParse(arguments[1], out newTime)) + Help(Client, alias, arguments); + + Client.World.Time = newTime; + + Client.SendMessage(string.Format("Setting time to {0}", arguments[1])); + + foreach (var client in Client.Server.Clients.Where(c => c.World.Equals(Client.World))) + client.QueuePacket(new TimeUpdatePacket(newTime)); + + break; + default: + Help(Client, alias, arguments); + break; + } + } + + public override void Help(IRemoteClient client, string alias, string[] arguments) + { + client.SendMessage("/time: Shows the current time."); + } + } +} \ No newline at end of file