Beispiel #1
0
 public static UserAction[] GetFilteredActions(string filter)
 {
     filter = filter.ToLower();
     if (filter.Split(new char[] { ' ' }).Length > 1)
     {
         string str = filter.Split(new char[] { ' ' })[0];
         List<UserAction> list = new List<UserAction>();
         foreach (UserAction action in AllActions)
         {
             foreach (string str2 in action.CommandWords)
             {
                 if (((str == str2) && (!action.AdminCommand || User.Current.IsAdmin)) && (ConfigSettings.GetString("SlashIgnore", "chicken canada canadian ").IndexOf(action.Description.ToLower() + " ") < 0))
                 {
                     list.Add(action);
                     break;
                 }
             }
         }
         return list.ToArray();
     }
     SortedList<string, UserAction> list2 = new SortedList<string, UserAction>();
     foreach (UserAction action in AllActions)
     {
         foreach (string str2 in action.CommandWords)
         {
             if ((str2.StartsWith(filter) && (!action.AdminCommand || User.Current.IsAdmin)) && (ConfigSettings.GetString("SlashIgnore", "chicken canada canadian  ").IndexOf(action.Description.ToLower() + " ") < 0))
             {
                 list2[action.Description] = action;
                 break;
             }
         }
     }
     UserAction[] array = new UserAction[list2.Count];
     list2.Values.CopyTo(array, 0);
     Array.Reverse(array);
     return array;
 }
Beispiel #2
0
 public static bool TryGetByPartialName(string commandName, out UserAction action)
 {
     UserAction[] filteredActions = GetFilteredActions(commandName);
     if (filteredActions.Length > 0)
     {
         action = filteredActions[0];
         return true;
     }
     action = null;
     return false;
 }
Beispiel #3
0
 public static UserAction AdminAction(string description, UserActionCommands command, string[] cmdWords, params UserActionArgument[] args)
 {
     UserAction action = new UserAction(description, command, cmdWords, args);
     action.mAdminCommand = true;
     return action;
 }
Beispiel #4
0
 public static bool TryGetByName(string commandName, out UserAction action)
 {
     for (int i = 0; i < AllActions.Length; i++)
     {
         if (Array.IndexOf<string>(AllActions[i].CommandWords, commandName.ToLower()) >= 0)
         {
             action = AllActions[i];
             return true;
         }
     }
     action = null;
     return false;
 }