2015-08-20 01:06:44 -04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
2017-05-26 18:49:27 -04:00
|
|
|
|
using System.Threading.Tasks;
|
2015-08-20 01:06:44 -04:00
|
|
|
|
|
2017-11-25 20:29:58 -05:00
|
|
|
|
using SharedLibrary.Objects;
|
|
|
|
|
|
2015-08-20 01:06:44 -04:00
|
|
|
|
namespace SharedLibrary
|
|
|
|
|
{
|
2017-11-15 16:04:13 -05:00
|
|
|
|
public class CommandArgument
|
|
|
|
|
{
|
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
public bool Required { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-20 01:06:44 -04:00
|
|
|
|
public abstract class Command
|
|
|
|
|
{
|
2017-11-15 16:04:13 -05:00
|
|
|
|
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];
|
2015-08-20 01:06:44 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Execute the command
|
2017-05-26 18:49:27 -04:00
|
|
|
|
abstract public Task ExecuteAsync(Event E);
|
2015-08-20 01:06:44 -04:00
|
|
|
|
|
|
|
|
|
public String Name { get; private set; }
|
|
|
|
|
public String Description { get; private set; }
|
2017-11-15 16:04:13 -05:00
|
|
|
|
public String Syntax => $"syntax: !{Alias} {String.Join(" ", Arguments.Select(a => $"<{(a.Required ? "" : "optional ")}{a.Name}>"))}";
|
2015-08-20 01:06:44 -04:00
|
|
|
|
public String Alias { get; private set; }
|
2017-11-15 16:04:13 -05:00
|
|
|
|
public int RequiredArgumentCount => Arguments.Count(c => c.Required);
|
2017-06-07 17:08:29 -04:00
|
|
|
|
public bool RequiresTarget { get; private set; }
|
2015-08-20 01:06:44 -04:00
|
|
|
|
public Player.Permission Permission { get; private set; }
|
2017-11-15 16:04:13 -05:00
|
|
|
|
public CommandArgument[] Arguments { get; private set; }
|
2015-08-20 01:06:44 -04:00
|
|
|
|
}
|
|
|
|
|
}
|