public static void Add(Command command, int Perm, string desc, int number = 1) { if (Perm > 120) { return; } OtherPerms otpe = new OtherPerms(); otpe.cmd = command; otpe.Permission = Perm; otpe.Description = desc; otpe.number = number; list.Add(otpe); }
public static OtherPerms Find(Command cmd, int number = 1) { foreach (OtherPerms OtPe in list) { if (OtPe.cmd == cmd && OtPe.number == number) { return OtPe; } } return null; }
public override void Use(Player p, string message) { if (checker==null){ checker = new Timer(60000); checker.Elapsed += new ElapsedEventHandler(checker_Elapsed); checker.Start(); } String[] incoming = message.Split(' '); if(incoming.Length == 2) { nowCmd = Command.all.Find(incoming[0]); if (nowCmd != null) { //command exists nowCmd.isIntervalized = true; nowCmd.intervalInMinutes = int.Parse(incoming[1]); nowCmd.intervalUsingPlayer = p; try { nowCmd.Use(nowCmd.intervalUsingPlayer, ""); } catch (Exception e) { Player.SendMessage(p, "An error occoured. please report this to the devs, cause this cmd seems to be not Interval-Compatible atm"); nowCmd.isIntervalized = false; return; } nowCmd.nextExecution = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, DateTime.Today.Hour, DateTime.Today.Minute + nowCmd.intervalInMinutes, 0); }else{ Player.SendMessage(p, "This command doesn't exist."); } }else if(incoming.Length == 1){ nowCmd = Command.all.Find(incoming[0]); if (nowCmd != null) { //command exists if (nowCmd.isIntervalized) { nowCmd.isIntervalized = false; Player.SendMessage(p, "Command will not be executed anymore in its Interval"); } } else { Player.SendMessage(p, "This command doesn't exist."); } }else{ this.Help(p); return; } nowCmd = null; }
public static int GetPerm(Command cmd, int number = 1) { OtherPerms otpe = Find(cmd, number); return otpe.Permission; }
public static int GetMaxNumber(Command cmd) { int i = 1; bool stop = false; while (stop == false) { OtherPerms op = Find(cmd, i); if (op == null) { stop = true; } else { i++; } } return (i - 1); }
public static OtherPerms Find(Command cmd, int number = 1) { return list.FirstOrDefault(OtPe => OtPe.cmd == cmd && OtPe.number == number); }
public bool Remove(Command cmd) { return commands.Remove(cmd); }
public bool Contains(Command cmd) { return commands.Contains(cmd); }
public void Add(Command cmd) { commands.Add(cmd); }
/// <summary> /// Check to see if this group can excute cmd /// </summary> /// <param name="cmd">The command object to check</param> /// <returns>True if this group can use it, false if they cant</returns> public bool CanExecute(Command cmd) { return commands.Contains(cmd); }
/// <summary> /// Add a command to the server /// </summary> /// <param name="command">The command to add</param> public void AddCommand(Command command) { all.Add(command); }