diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 7a48da37..73bedfab 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -66,20 +66,26 @@ namespace TShockAPI public List Names { get; protected set; } public bool AllowServer { get; set; } public bool DoLog { get; set; } - public string Permission { get; protected set; } + public List Permissions { get; protected set; } private CommandDelegate command; + public Command(List permissionsneeded, CommandDelegate cmd, params string[] names) + : this(cmd, names) + { + Permissions = permissionsneeded; + } + public Command(string permissionneeded, CommandDelegate cmd, params string[] names) : this(cmd, names) { - Permission = permissionneeded; + Permissions = new List { permissionneeded }; } public Command(CommandDelegate cmd, params string[] names) { if (names == null || names.Length < 1) throw new NotSupportedException(); - Permission = null; + Permissions = null; Names = new List(names); command = cmd; AllowServer = true; @@ -88,7 +94,7 @@ namespace TShockAPI public bool Run(string msg, TSPlayer ply, List parms) { - if (!ply.Group.HasPermission(Permission)) + if (!CanRun(ply)) return false; try @@ -111,7 +117,14 @@ namespace TShockAPI public bool CanRun(TSPlayer ply) { - return ply.Group.HasPermission(Permission); + if (Permissions == null) + return true; + foreach (var Permission in Permissions) + { + if (ply.Group.HasPermission(Permission)) + return true; + } + return false; } } diff --git a/TShockAPI/Permissions.cs b/TShockAPI/Permissions.cs index f7c1b2f1..3f0654fc 100644 --- a/TShockAPI/Permissions.cs +++ b/TShockAPI/Permissions.cs @@ -191,7 +191,7 @@ namespace TShockAPI { if (Commands.ChatCommands.Count < 1) Commands.InitCommands(); - return Commands.ChatCommands.Where(c => c.Permission == perm).ToList(); + return Commands.ChatCommands.Where(c => c.Permissions.Contains(perm)).ToList(); } ///