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;
|
2018-11-05 22:01:29 -05:00
|
|
|
|
using SharedLibraryCore.Database.Models;
|
2017-11-25 20:29:58 -05:00
|
|
|
|
|
2018-04-08 02:44:42 -04:00
|
|
|
|
namespace SharedLibraryCore
|
2015-08-20 01:06:44 -04:00
|
|
|
|
{
|
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
|
|
|
|
|
{
|
2018-11-05 22:01:29 -05:00
|
|
|
|
public Command(String commandName, String commandDescription, String commandAlias, EFClient.Permission requiredPermission, bool requiresTarget, CommandArgument[] param = null)
|
2017-11-15 16:04:13 -05:00
|
|
|
|
{
|
|
|
|
|
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
|
2018-04-13 02:32:30 -04:00
|
|
|
|
abstract public Task ExecuteAsync(GameEvent E);
|
2015-08-20 01:06:44 -04:00
|
|
|
|
|
|
|
|
|
public String Name { get; private set; }
|
|
|
|
|
public String Description { get; private set; }
|
2018-05-05 16:36:26 -04:00
|
|
|
|
public String Syntax => $"{Utilities.CurrentLocalization.LocalizationIndex["COMMAND_HELP_SYNTAX"]} !{Alias} {String.Join(" ", Arguments.Select(a => $"<{(a.Required ? "" : Utilities.CurrentLocalization.LocalizationIndex["COMMAND_HELP_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; }
|
2018-11-05 22:01:29 -05:00
|
|
|
|
public EFClient.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
|
|
|
|
}
|
|
|
|
|
}
|