diff --git a/TrueCraft.API/Server/ICommand.cs b/TrueCraft.API/Server/ICommand.cs index 4e4b609..798710b 100644 --- a/TrueCraft.API/Server/ICommand.cs +++ b/TrueCraft.API/Server/ICommand.cs @@ -11,7 +11,7 @@ namespace TrueCraft.API.Server string Name { get; } string Description { get; } string[] Aliases { get; } - void Handle(IRemoteClient Client, string alias, string[] arguments); + void Handle(IRemoteClient client, string alias, string[] arguments); void Help(IRemoteClient client, string alias, string[] arguments); } } \ No newline at end of file diff --git a/TrueCraft/Commands/DebugCommands.cs b/TrueCraft/Commands/DebugCommands.cs index 55af1aa..39b1163 100644 --- a/TrueCraft/Commands/DebugCommands.cs +++ b/TrueCraft/Commands/DebugCommands.cs @@ -1,8 +1,4 @@ -using System.Collections.Generic; -using System.Text; -using TrueCraft.Core.Windows; -using TrueCraft.API; -using TrueCraft.API.Networking; +using TrueCraft.API.Networking; using TrueCraft.Core.Networking.Packets; namespace TrueCraft.Commands @@ -24,14 +20,14 @@ namespace TrueCraft.Commands get { return new string[0]; } } - public override void Handle(IRemoteClient Client, string alias, string[] arguments) + public override void Handle(IRemoteClient client, string alias, string[] arguments) { if (arguments.Length != 0) { - Help(Client, alias, arguments); + Help(client, alias, arguments); return; } - Client.SendMessage(Client.Entity.Position.ToString()); + client.SendMessage(client.Entity.Position.ToString()); } public override void Help(IRemoteClient client, string alias, string[] arguments) @@ -57,14 +53,14 @@ namespace TrueCraft.Commands get { return new string[0]; } } - public override void Handle(IRemoteClient Client, string alias, string[] arguments) + public override void Handle(IRemoteClient client, string alias, string[] arguments) { if (arguments.Length != 0) { - Help(Client, alias, arguments); + Help(client, alias, arguments); return; } - Client.EnableLogging = !Client.EnableLogging; + client.EnableLogging = !client.EnableLogging; } public override void Help(IRemoteClient client, string alias, string[] arguments) @@ -90,14 +86,14 @@ namespace TrueCraft.Commands get { return new string[0]; } } - public override void Handle(IRemoteClient Client, string alias, string[] arguments) + public override void Handle(IRemoteClient client, string alias, string[] arguments) { if (arguments.Length != 0) { - Help(Client, alias, arguments); + Help(client, alias, arguments); return; } - Client.QueuePacket(new WindowItemsPacket(0, Client.Inventory.GetSlots())); + client.QueuePacket(new WindowItemsPacket(0, client.Inventory.GetSlots())); } public override void Help(IRemoteClient client, string alias, string[] arguments) diff --git a/TrueCraft/Commands/HelpCommand.cs b/TrueCraft/Commands/HelpCommand.cs index 58cf4ec..de6f4e5 100644 --- a/TrueCraft/Commands/HelpCommand.cs +++ b/TrueCraft/Commands/HelpCommand.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using TrueCraft.API.Networking; using TrueCraft.API.Server; @@ -19,63 +16,58 @@ namespace TrueCraft.Commands get { return "Command help menu."; } } - public override void Handle(IRemoteClient Client, string alias, string[] arguments) + public override void Handle(IRemoteClient client, string alias, string[] arguments) { if (arguments.Length < 1) { - Help(Client, alias, arguments); + Help(client, alias, arguments); return; } - string Identifier; + var identifier = arguments.Length >= 1 ? arguments[0] : "0"; - if (arguments.Length >= 1) - Identifier = arguments[0]; - else - Identifier = "0"; - - ICommand Found = null; - if ((Found = Program.CommandManager.FindByName(Identifier)) != null) + ICommand found; + if ((found = Program.CommandManager.FindByName(identifier)) != null) { - Found.Handle(Client, Identifier, new string[0]); + found.Handle(client, identifier, new string[0]); return; } - else if ((Found = Program.CommandManager.FindByAlias(Identifier)) != null) + else if ((found = Program.CommandManager.FindByAlias(identifier)) != null) { - Found.Help(Client, Identifier, new string[0]); + found.Help(client, identifier, new string[0]); return; } - int PageNumber = 0; - if (int.TryParse(Identifier, out PageNumber)) + int pageNumber; + if (int.TryParse(identifier, out pageNumber)) { - HelpPage(Client, PageNumber); + HelpPage(client, pageNumber); return; } - Help(Client, alias, arguments); + Help(client, alias, arguments); } - public void HelpPage(IRemoteClient Client, int Page) + public void HelpPage(IRemoteClient client, int page) { - int PerPage = 5; - int Pages = (int)Math.Floor((double)(Program.CommandManager.Commands.Count / PerPage)); - if ((Program.CommandManager.Commands.Count % PerPage) > 0) - Pages++; + const int perPage = 5; + int numPages = (int)Math.Floor(((double)Program.CommandManager.Commands.Count / perPage)); + if ((Program.CommandManager.Commands.Count % perPage) > 0) + numPages++; - if (Page < 1 || Page > Pages) - Page = 1; + if (page < 1 || page > numPages) + page = 1; - int StartingIndex = (Page - 1) * PerPage; - Client.SendMessage("--Help Page " + Page + " of " + Pages + "--"); - for (int i = 0; i < PerPage; i++) + int startingIndex = (page - 1) * perPage; + client.SendMessage("--Help page " + page + " of " + numPages + "--"); + for (int i = 0; i < perPage; i++) { - int Index = StartingIndex + i; - if (Index > Program.CommandManager.Commands.Count - 1) + int index = startingIndex + i; + if (index > Program.CommandManager.Commands.Count - 1) { break; } - ICommand C = Program.CommandManager.Commands[Index]; - Client.SendMessage("/" + C.Name + " - " + C.Description); + var command = Program.CommandManager.Commands[index]; + client.SendMessage("/" + command.Name + " - " + command.Description); } } diff --git a/TrueCraft/Commands/PingCommand.cs b/TrueCraft/Commands/PingCommand.cs index c32c9f7..d14fb8f 100644 --- a/TrueCraft/Commands/PingCommand.cs +++ b/TrueCraft/Commands/PingCommand.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using TrueCraft.API.Networking; +using TrueCraft.API.Networking; namespace TrueCraft.Commands { @@ -18,9 +14,9 @@ namespace TrueCraft.Commands get { return "Ping pong"; } } - public override void Handle(IRemoteClient Client, string alias, string[] arguments) + public override void Handle(IRemoteClient client, string alias, string[] arguments) { - Client.SendMessage("Pong!"); + client.SendMessage("Pong!"); } public override void Help(IRemoteClient client, string alias, string[] arguments) diff --git a/TrueCraft/Commands/TimeCommand.cs b/TrueCraft/Commands/TimeCommand.cs index 5c73135..c8c154d 100644 --- a/TrueCraft/Commands/TimeCommand.cs +++ b/TrueCraft/Commands/TimeCommand.cs @@ -22,32 +22,32 @@ namespace TrueCraft.Commands get { return new string[0]; } } - public override void Handle(IRemoteClient Client, string alias, string[] arguments) + public override void Handle(IRemoteClient client, string alias, string[] arguments) { switch (arguments.Length) { case 0: - Client.SendMessage(Client.World.Time.ToString()); + client.SendMessage(client.World.Time.ToString()); break; case 2: if (!arguments[0].Equals("set")) - Help(Client, alias, arguments); + Help(client, alias, arguments); int newTime; if(!Int32.TryParse(arguments[1], out newTime)) - Help(Client, alias, arguments); + Help(client, alias, arguments); - Client.World.Time = newTime; + client.World.Time = newTime; - Client.SendMessage(string.Format("Setting time to {0}", arguments[1])); + 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)); + foreach (var remoteClient in client.Server.Clients.Where(c => c.World.Equals(client.World))) + remoteClient.QueuePacket(new TimeUpdatePacket(newTime)); break; default: - Help(Client, alias, arguments); + Help(client, alias, arguments); break; } } diff --git a/TrueCraft/TrueCraft.csproj b/TrueCraft/TrueCraft.csproj index c790758..47c097f 100644 --- a/TrueCraft/TrueCraft.csproj +++ b/TrueCraft/TrueCraft.csproj @@ -1,4 +1,4 @@ - + Debug @@ -44,6 +44,7 @@ + @@ -78,9 +79,7 @@ - - - +