add unlink command

fix parsing names with colors codes enabled
This commit is contained in:
RaidMax
2019-10-11 15:26:13 -05:00
parent 6b27beb355
commit b992f4d910
5 changed files with 48 additions and 1 deletions

View File

@ -86,12 +86,13 @@ namespace SharedLibraryCore.Commands
if (E.Target == null && C.RequiresTarget) // Find active player including quotes (multiple words)
{
matchingPlayers = E.Owner.GetClientByName(E.Data.Trim());
matchingPlayers = E.Owner.GetClientByName(E.Data);
if (matchingPlayers.Count > 1)
{
E.Origin.Tell(loc["COMMAND_TARGET_MULTI"]);
throw new CommandException($"{E.Origin} had multiple players found for {C.Name}");
}
else if (matchingPlayers.Count == 1)
{
E.Target = matchingPlayers.First();

View File

@ -0,0 +1,18 @@
using SharedLibraryCore.Database.Models;
using System.Threading.Tasks;
namespace SharedLibraryCore.Commands
{
public class UnlinkClientCommand : Command
{
public UnlinkClientCommand() :
base("unlinkclient", Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_UNLINK_CLIENT_DESC"], "uc", EFClient.Permission.Administrator, true)
{ }
public override async Task ExecuteAsync(GameEvent E)
{
await E.Owner.Manager.GetClientService().UnlinkClient(E.Target.ClientId);
E.Origin.Tell(Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_UNLINK_CLIENT_SUCCESS"].FormatExt(E.Target));
}
}
}