mirror of
https://github.com/RaidMax/IW4M-Admin.git
synced 2025-06-10 15:20:48 -05:00
migrating to .NET Core 2.0
This commit is contained in:
39
SharedLibraryCore/Command.cs
Normal file
39
SharedLibraryCore/Command.cs
Normal file
@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using SharedLibraryCore.Objects;
|
||||
|
||||
namespace SharedLibraryCore
|
||||
{
|
||||
public class CommandArgument
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public bool Required { get; set; }
|
||||
}
|
||||
|
||||
public abstract class Command
|
||||
{
|
||||
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
|
||||
abstract public Task ExecuteAsync(Event E);
|
||||
|
||||
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 => Arguments.Count(c => c.Required);
|
||||
public bool RequiresTarget { get; private set; }
|
||||
public Player.Permission Permission { get; private set; }
|
||||
public CommandArgument[] Arguments { get; private set; }
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user