public void Use(IClient iClient, string commandName, string[] tokens) { Client client = iClient as Client; if (tokens.Length == 0) { client.SendMessage("Use " + ChatColor.Teal + "/help build" + ChatColor.White + " for a list of building commands."); client.SendMessage("Use " + ChatColor.Teal + "/help mod" + ChatColor.White + " for a list of moderation commands."); client.SendMessage("Use " + ChatColor.Teal + "/help information" + ChatColor.White + " for a list of information commands."); client.SendMessage("Use " + ChatColor.Teal + "/help other" + ChatColor.White + " for a list of other commands."); client.SendMessage("Use " + ChatColor.Teal + "/help short" + ChatColor.White + " for a list of shortcuts."); } else if (tokens.Length > 0) { string message; switch (tokens[0].ToLower()) { case "build": message = (from IClientCommand c in ClientCommandHandler.GetCommands() where c.Type == CommandType.Build && client.Owner.CanUseCommand(c) select c).Aggregate("", (current, c) => current + (", " + c.Name)); if (message == "") { client.SendMessage(ChatColor.Red + "There are no commands of this type that you can use."); return; } message = message.Remove(0, 1); client.SendMessage(message); break; case "mod": message = (from IClientCommand c in ClientCommandHandler.GetCommands() where c.Type == CommandType.Mod && client.Owner.CanUseCommand(c) select c).Aggregate("", (current, c) => current + (", " + c.Name)); if (message == "") { client.SendMessage(ChatColor.Red + "There are no commands of this type that you can use."); return; } message = message.Remove(0, 1); client.SendMessage(message); break; case "information": case "info": message = (from IClientCommand c in ClientCommandHandler.GetCommands() where c.Type == CommandType.Information && client.Owner.CanUseCommand(c) select c).Aggregate("", (current, c) => current + (", " + c.Name)); if (message == "") { client.SendMessage(ChatColor.Red + "There are no commands of this type that you can use."); return; } message = message.Remove(0, 1); client.SendMessage(message); break; case "other": message = (from IClientCommand c in ClientCommandHandler.GetCommands() where c.Type == CommandType.Other && client.Owner.CanUseCommand(c) select c).Aggregate("", (current, c) => current + (", " + c.Name)); if (message == "") { client.SendMessage(ChatColor.Red + "There are no commands of this type that you can use."); return; } message = message.Remove(0, 1); client.SendMessage(message); break; case "short": message = (from IClientCommand c in ClientCommandHandler.GetCommands() where client.Owner.CanUseCommand(c) && !string.IsNullOrEmpty(c.Shortcut) select c).Aggregate("", (current, c) => current + (", " + c.Shortcut)); if (message == "") { client.SendMessage(ChatColor.Red + "There are no commands of this type that you can use."); return; } message = message.Remove(0, 1); client.SendMessage(message); break; default: IClientCommand cmd; try { cmd = ClientCommandHandler.Find(tokens[0]) as IClientCommand; } catch (MultipleCommandsMatchException e) { client.SendMessage(ChatColor.Red + "Multiple commands has been found:"); foreach (var s in e.Commands) { client.SendMessage(string.Format(" {0}{1}", ChatColor.Red, s)); } return; } catch (CommandNotFoundException e) { client.SendMessage(e.Message); return; } try { cmd.Help(client); client.SendMessage("Type: " + cmd.Type.ToString()); if (client.Owner.CanUseCommand(cmd)) { client.SendMessage(ChatColor.BrightGreen + "You can use this command."); } else { client.SendMessage(ChatColor.Red + "You cannot use this command."); } } catch (Exception e) { client.SendMessage("There was an error while accessing the help for this command."); client.Owner.Server.Logger.Log(e); } break; } } }