1
0
mirror of https://github.com/RaidMax/IW4M-Admin.git synced 2025-06-12 08:08:06 -05:00

Added CommandArgument class to generate syntax for commands. changed Command constructor

tweaked help command
/pubbans is working properly now
plugins properties changed to expression
This commit is contained in:
RaidMax
2017-11-15 15:04:13 -06:00
parent 89381bcc7d
commit a56f386644
17 changed files with 391 additions and 189 deletions

View File

@ -1,21 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SharedLibrary
{
public class CommandArgument
{
public string Name { get; set; }
public bool Required { get; set; }
}
public abstract class Command
{
public Command(String N, String D, String A, Player.Permission P, int args, bool nT)
{
Name = N;
Description = D;
Alias = A;
Permission = P;
RequiredArgumentCount = args;
RequiresTarget = nT;
public Command(String commandName, String commandDescription, String commandAlias, Player.Permission requiredPermission, bool requiresTarget, CommandArgument[] param = null)
{
Name = commandName;
Description = commandDescription;
Alias = commandAlias;
Permission = requiredPermission;
RequiresTarget = requiresTarget;
Arguments = param ?? new CommandArgument[0];
}
//Execute the command
@ -23,9 +27,11 @@ namespace SharedLibrary
public String Name { get; private set; }
public String Description { get; private set; }
public String Syntax => $"syntax: !{Alias} {String.Join(" ", Arguments.Select(a => $"<{(a.Required ? "" : "optional ")}{a.Name}>"))}";
public String Alias { get; private set; }
public int RequiredArgumentCount { get; private set; }
public int RequiredArgumentCount => Arguments.Count(c => c.Required);
public bool RequiresTarget { get; private set; }
public Player.Permission Permission { get; private set; }
public CommandArgument[] Arguments { get; private set; }
}
}