2018-04-08 02:44:42 -04:00
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
2020-01-26 19:06:50 -05:00
|
|
|
|
using SharedLibraryCore.Configuration;
|
2018-04-08 02:44:42 -04:00
|
|
|
|
using SharedLibraryCore.Database;
|
|
|
|
|
using SharedLibraryCore.Database.Models;
|
2019-05-29 17:55:35 -04:00
|
|
|
|
using SharedLibraryCore.Helpers;
|
2020-01-26 19:06:50 -05:00
|
|
|
|
using SharedLibraryCore.Interfaces;
|
2018-04-08 02:44:42 -04:00
|
|
|
|
using SharedLibraryCore.Services;
|
2018-04-02 01:25:06 -04:00
|
|
|
|
using System;
|
2015-03-08 17:20:10 -04:00
|
|
|
|
using System.Collections.Generic;
|
2017-06-01 13:42:28 -04:00
|
|
|
|
using System.Linq;
|
2018-06-02 00:48:10 -04:00
|
|
|
|
using System.Security.Cryptography;
|
2018-04-02 01:25:06 -04:00
|
|
|
|
using System.Text;
|
2018-05-05 16:36:26 -04:00
|
|
|
|
using System.Text.RegularExpressions;
|
2017-11-25 20:29:58 -05:00
|
|
|
|
using System.Threading.Tasks;
|
2019-04-25 22:05:35 -04:00
|
|
|
|
using static SharedLibraryCore.Database.Models.EFClient;
|
2017-11-25 20:29:58 -05:00
|
|
|
|
|
2018-04-08 02:44:42 -04:00
|
|
|
|
namespace SharedLibraryCore.Commands
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Quits IW4MAdmin
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class QuitCommand : Command
|
2017-05-26 18:49:27 -04:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
public QuitCommand(CommandConfiguration config, ITranslationLookup translationLookup) : base(config, translationLookup)
|
|
|
|
|
{
|
|
|
|
|
Name = "quit";
|
|
|
|
|
Description = _translationLookup["COMMANDS_QUIT_DESC"];
|
|
|
|
|
Alias = "q";
|
|
|
|
|
Permission = Permission.Owner;
|
|
|
|
|
RequiresTarget = false;
|
|
|
|
|
}
|
2017-05-26 18:49:27 -04:00
|
|
|
|
|
2018-04-13 02:32:30 -04:00
|
|
|
|
public override Task ExecuteAsync(GameEvent E)
|
2017-05-26 18:49:27 -04:00
|
|
|
|
{
|
2019-05-08 21:34:17 -04:00
|
|
|
|
E.Owner.Manager.Stop();
|
|
|
|
|
return Task.CompletedTask;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-26 19:06:50 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Restarts IW4MAdmin
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class RestartCommand : Command
|
2019-05-08 21:34:17 -04:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
public RestartCommand(CommandConfiguration config, ITranslationLookup translationLookup) : base(config, translationLookup)
|
|
|
|
|
{
|
|
|
|
|
Name = "restart";
|
|
|
|
|
Description = _translationLookup["COMMANDS_RESTART_DESC"];
|
|
|
|
|
Alias = "res";
|
|
|
|
|
Permission = Permission.Owner;
|
|
|
|
|
RequiresTarget = false;
|
|
|
|
|
}
|
2019-05-08 21:34:17 -04:00
|
|
|
|
|
|
|
|
|
public override Task ExecuteAsync(GameEvent E)
|
|
|
|
|
{
|
2019-06-09 10:50:58 -04:00
|
|
|
|
MetaService.Clear();
|
2019-05-08 21:34:17 -04:00
|
|
|
|
E.Owner.Manager.Restart();
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Origin.Tell(_translationLookup["COMMANDS_RESTART_SUCCESS"]);
|
2019-05-08 21:34:17 -04:00
|
|
|
|
return Task.CompletedTask;
|
2017-05-26 18:49:27 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-26 19:06:50 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Claims ownership of the server
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class OwnerCommand : Command
|
2017-08-17 19:28:08 -04:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
public OwnerCommand(CommandConfiguration config, ITranslationLookup translationLookup) : base(config, translationLookup)
|
|
|
|
|
{
|
|
|
|
|
Name = "owner";
|
|
|
|
|
Description = _translationLookup["COMMANDS_OWNER_DESC"];
|
|
|
|
|
Alias = "iamgod";
|
|
|
|
|
Permission = Permission.User;
|
|
|
|
|
RequiresTarget = false;
|
|
|
|
|
}
|
2015-03-08 17:20:10 -04:00
|
|
|
|
|
2018-04-13 02:32:30 -04:00
|
|
|
|
public override async Task ExecuteAsync(GameEvent E)
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2020-05-16 12:54:01 -04:00
|
|
|
|
// they're trying to set the console's permission level... sigh...
|
|
|
|
|
if (E.Origin.Level == Permission.Console)
|
|
|
|
|
{
|
|
|
|
|
E.Origin.Tell(_translationLookup["COMMANDS_OWNER_IDIOT"]);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-24 22:34:20 -04:00
|
|
|
|
if (await (E.Owner.Manager.GetClientService() as ClientService).GetOwnerCount() == 0 &&
|
2019-04-11 21:43:05 -04:00
|
|
|
|
!E.Origin.SetLevel(EFClient.Permission.Owner, Utilities.IW4MAdminClient(E.Owner)).Failed)
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Origin.Tell(_translationLookup["COMMANDS_OWNER_SUCCESS"]);
|
2015-03-08 17:20:10 -04:00
|
|
|
|
}
|
|
|
|
|
else
|
2018-09-29 15:52:22 -04:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Origin.Tell(_translationLookup["COMMANDS_OWNER_FAIL"]);
|
2018-09-29 15:52:22 -04:00
|
|
|
|
}
|
2015-03-08 17:20:10 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-26 19:06:50 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Warns given client for reason
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class WarnCommand : Command
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
public WarnCommand(CommandConfiguration config, ITranslationLookup translationLookup) : base(config, translationLookup)
|
|
|
|
|
{
|
|
|
|
|
Name = "warn";
|
|
|
|
|
Description = _translationLookup["COMMANDS_WARN_DESC"];
|
|
|
|
|
Alias = "w";
|
|
|
|
|
Permission = Permission.Trusted;
|
|
|
|
|
RequiresTarget = true;
|
|
|
|
|
Arguments = new[]
|
|
|
|
|
{
|
|
|
|
|
new CommandArgument()
|
2017-11-15 16:04:13 -05:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
Name = _translationLookup["COMMANDS_ARGS_PLAYER"],
|
|
|
|
|
Required = true
|
|
|
|
|
},
|
|
|
|
|
new CommandArgument()
|
|
|
|
|
{
|
|
|
|
|
Name = _translationLookup["COMMANDS_ARGS_REASON"],
|
|
|
|
|
Required = true
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
2015-03-08 17:20:10 -04:00
|
|
|
|
|
2018-09-29 22:49:12 -04:00
|
|
|
|
public override Task ExecuteAsync(GameEvent E)
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2018-09-29 22:49:12 -04:00
|
|
|
|
if (E.Target.Warn(E.Data, E.Origin).Failed)
|
2018-09-02 22:25:09 -04:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Origin.Tell(_translationLookup["COMMANDS_WARN_FAIL"].FormatExt(E.Target.Name));
|
2018-09-02 22:25:09 -04:00
|
|
|
|
}
|
2018-09-29 22:49:12 -04:00
|
|
|
|
|
|
|
|
|
return Task.CompletedTask;
|
2015-03-08 17:20:10 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-26 19:06:50 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Clears all warnings for given client
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class WarnClearCommand : Command
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
public WarnClearCommand(CommandConfiguration config, ITranslationLookup translationLookup) : base(config, translationLookup)
|
|
|
|
|
{
|
|
|
|
|
Name = "warnclear";
|
|
|
|
|
Description = _translationLookup["COMMANDS_WARNCLEAR_DESC"];
|
|
|
|
|
Alias = "wc";
|
|
|
|
|
Permission = Permission.Trusted;
|
|
|
|
|
RequiresTarget = true;
|
|
|
|
|
Arguments = new[]
|
|
|
|
|
{
|
|
|
|
|
new CommandArgument()
|
2017-11-15 16:04:13 -05:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
Name = _translationLookup["COMMANDS_ARGS_PLAYER"],
|
|
|
|
|
Required = true
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
2015-03-08 17:20:10 -04:00
|
|
|
|
|
2018-09-29 22:49:12 -04:00
|
|
|
|
public override Task ExecuteAsync(GameEvent E)
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2018-09-29 22:49:12 -04:00
|
|
|
|
if (!E.Target.WarnClear(E.Origin).Failed)
|
2018-09-29 15:52:22 -04:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Owner.Broadcast(_translationLookup["COMMANDS_WARNCLEAR_SUCCESS"].FormatExt(E.Target.Name));
|
2018-09-29 15:52:22 -04:00
|
|
|
|
}
|
2018-09-29 22:49:12 -04:00
|
|
|
|
|
|
|
|
|
return Task.CompletedTask;
|
2015-03-08 17:20:10 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-26 19:06:50 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Kicks client for given reason
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class KickCommand : Command
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
public KickCommand(CommandConfiguration config, ITranslationLookup translationLookup) : base(config, translationLookup)
|
|
|
|
|
{
|
|
|
|
|
Name = "kick";
|
|
|
|
|
Description = _translationLookup["COMMANDS_KICK_DESC"];
|
|
|
|
|
Alias = "k";
|
|
|
|
|
Permission = Permission.Moderator;
|
|
|
|
|
RequiresTarget = true;
|
|
|
|
|
Arguments = new[]
|
2017-11-15 16:04:13 -05:00
|
|
|
|
{
|
|
|
|
|
new CommandArgument()
|
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
Name = _translationLookup["COMMANDS_ARGS_PLAYER"],
|
2017-11-15 16:04:13 -05:00
|
|
|
|
Required = true
|
|
|
|
|
},
|
|
|
|
|
new CommandArgument()
|
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
Name = _translationLookup["COMMANDS_ARGS_REASON"],
|
2018-04-24 18:01:27 -04:00
|
|
|
|
Required = true
|
2017-11-15 16:04:13 -05:00
|
|
|
|
}
|
2020-01-26 19:06:50 -05:00
|
|
|
|
};
|
|
|
|
|
}
|
2015-03-08 17:20:10 -04:00
|
|
|
|
|
2018-04-13 02:32:30 -04:00
|
|
|
|
public override async Task ExecuteAsync(GameEvent E)
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2019-05-08 21:34:17 -04:00
|
|
|
|
switch ((await E.Target.Kick(E.Data, E.Origin).WaitAsync(Utilities.DefaultCommandTimeout, E.Owner.Manager.CancellationToken)).FailReason)
|
|
|
|
|
{
|
|
|
|
|
case GameEvent.EventFailReason.None:
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Origin.Tell(_translationLookup["COMMANDS_KICK_SUCCESS"].FormatExt(E.Target.Name));
|
2019-05-08 21:34:17 -04:00
|
|
|
|
break;
|
|
|
|
|
case GameEvent.EventFailReason.Exception:
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Origin.Tell(_translationLookup["SERVER_ERROR_COMMAND_INGAME"]);
|
2019-05-08 21:34:17 -04:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Origin.Tell(_translationLookup["COMMANDS_KICK_FAIL"].FormatExt(E.Target.Name));
|
2019-05-08 21:34:17 -04:00
|
|
|
|
break;
|
|
|
|
|
}
|
2015-03-08 17:20:10 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-26 19:06:50 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Prints out a message to all clients on the server
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class SayCommand : Command
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
public SayCommand(CommandConfiguration config, ITranslationLookup translationLookup) : base(config, translationLookup)
|
|
|
|
|
{
|
|
|
|
|
Name = "say";
|
|
|
|
|
Description = _translationLookup["COMMANDS_SAY_DESC"];
|
|
|
|
|
Alias = "s";
|
|
|
|
|
Permission = Permission.Moderator;
|
|
|
|
|
RequiresTarget = false;
|
|
|
|
|
Arguments = new[]
|
|
|
|
|
{
|
|
|
|
|
new CommandArgument()
|
2017-11-15 16:04:13 -05:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
Name = _translationLookup["COMMANDS_ARGS_MESSAGE"],
|
|
|
|
|
Required = true
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
2015-03-08 17:20:10 -04:00
|
|
|
|
|
2018-09-29 15:52:22 -04:00
|
|
|
|
public override Task ExecuteAsync(GameEvent E)
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2018-09-29 15:52:22 -04:00
|
|
|
|
E.Owner.Broadcast($"{(E.Owner.GameName == Server.Game.IW4 ? "^:" : "")}{E.Origin.Name} - ^6{E.Data}^7", E.Origin);
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Origin.Tell(_translationLookup["COMMANDS_SAY_SUCCESS"]);
|
2018-09-29 15:52:22 -04:00
|
|
|
|
return Task.CompletedTask;
|
2015-03-08 17:20:10 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-26 19:06:50 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Temporarily bans a client
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class TempBanCommand : Command
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
public TempBanCommand(CommandConfiguration config, ITranslationLookup translationLookup) : base(config, translationLookup)
|
|
|
|
|
{
|
|
|
|
|
Name = "tempban";
|
|
|
|
|
Description = _translationLookup["COMMANDS_TEMPBAN_DESC"];
|
|
|
|
|
Alias = "tb";
|
|
|
|
|
Permission = Permission.Administrator;
|
|
|
|
|
RequiresTarget = true;
|
|
|
|
|
Arguments = new[]
|
|
|
|
|
{
|
|
|
|
|
new CommandArgument()
|
2017-11-15 16:04:13 -05:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
Name = _translationLookup["COMMANDS_ARGS_PLAYER"],
|
|
|
|
|
Required = true
|
|
|
|
|
},
|
|
|
|
|
new CommandArgument()
|
|
|
|
|
{
|
|
|
|
|
Name = _translationLookup["COMMANDS_ARGS_DURATION"],
|
|
|
|
|
Required = true,
|
|
|
|
|
},
|
|
|
|
|
new CommandArgument()
|
|
|
|
|
{
|
|
|
|
|
Name = _translationLookup["COMMANDS_ARGS_REASON"],
|
|
|
|
|
Required = true
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
2015-03-08 17:20:10 -04:00
|
|
|
|
|
2018-10-02 13:39:08 -04:00
|
|
|
|
private static readonly string TempBanRegex = @"([0-9]+\w+)\ (.+)";
|
|
|
|
|
|
2018-04-13 02:32:30 -04:00
|
|
|
|
public override async Task ExecuteAsync(GameEvent E)
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2018-10-02 13:39:08 -04:00
|
|
|
|
var match = Regex.Match(E.Data, TempBanRegex);
|
|
|
|
|
if (match.Success)
|
|
|
|
|
{
|
|
|
|
|
string tempbanReason = match.Groups[2].ToString();
|
|
|
|
|
var length = match.Groups[1].ToString().ParseTimespan();
|
|
|
|
|
|
2018-10-15 20:51:04 -04:00
|
|
|
|
if (length > E.Owner.Manager.GetApplicationSettings().Configuration().MaximumTempBanTime)
|
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Origin.Tell(_translationLookup["COMMANDS_TEMPBAN_FAIL_TOOLONG"]);
|
2018-10-15 20:51:04 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
{
|
2019-05-08 21:34:17 -04:00
|
|
|
|
switch ((await E.Target.TempBan(tempbanReason, length, E.Origin).WaitAsync(Utilities.DefaultCommandTimeout, E.Owner.Manager.CancellationToken)).FailReason)
|
|
|
|
|
{
|
|
|
|
|
case GameEvent.EventFailReason.None:
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Origin.Tell(_translationLookup["COMMANDS_TEMPBAN_SUCCESS"].FormatExt(E.Target, length.TimeSpanText()));
|
2019-05-08 21:34:17 -04:00
|
|
|
|
break;
|
|
|
|
|
case GameEvent.EventFailReason.Exception:
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Origin.Tell(_translationLookup["SERVER_ERROR_COMMAND_INGAME"]);
|
2019-05-08 21:34:17 -04:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Origin.Tell(_translationLookup["COMMANDS_TEMPBAN_FAIL"].FormatExt(E.Target.Name));
|
2019-05-08 21:34:17 -04:00
|
|
|
|
break;
|
|
|
|
|
}
|
2018-10-15 20:51:04 -04:00
|
|
|
|
}
|
2018-10-02 13:39:08 -04:00
|
|
|
|
}
|
2015-03-08 17:20:10 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-26 19:06:50 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Permanently bans a client
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class BanCommand : Command
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
public BanCommand(CommandConfiguration config, ITranslationLookup translationLookup) : base(config, translationLookup)
|
|
|
|
|
{
|
|
|
|
|
Name = "ban";
|
|
|
|
|
Description = _translationLookup["COMMANDS_BAN_DESC"];
|
|
|
|
|
Alias = "b";
|
|
|
|
|
Permission = Permission.SeniorAdmin;
|
|
|
|
|
RequiresTarget = true;
|
|
|
|
|
Arguments = new[]
|
2017-11-15 16:04:13 -05:00
|
|
|
|
{
|
|
|
|
|
new CommandArgument()
|
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
Name = _translationLookup["COMMANDS_ARGS_PLAYER"],
|
2017-11-15 16:04:13 -05:00
|
|
|
|
Required = true
|
|
|
|
|
},
|
|
|
|
|
new CommandArgument()
|
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
Name = _translationLookup["COMMANDS_ARGS_REASON"],
|
2017-11-16 18:09:19 -05:00
|
|
|
|
Required = true
|
2017-11-15 16:04:13 -05:00
|
|
|
|
}
|
2020-01-26 19:06:50 -05:00
|
|
|
|
};
|
|
|
|
|
}
|
2015-03-08 17:20:10 -04:00
|
|
|
|
|
2018-04-13 02:32:30 -04:00
|
|
|
|
public override async Task ExecuteAsync(GameEvent E)
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2019-05-08 21:34:17 -04:00
|
|
|
|
switch ((await E.Target.Ban(E.Data, E.Origin, false).WaitAsync(Utilities.DefaultCommandTimeout, E.Owner.Manager.CancellationToken)).FailReason)
|
|
|
|
|
{
|
|
|
|
|
case GameEvent.EventFailReason.None:
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Origin.Tell(_translationLookup["COMMANDS_BAN_SUCCESS"].FormatExt(E.Target.Name));
|
2019-05-08 21:34:17 -04:00
|
|
|
|
break;
|
|
|
|
|
case GameEvent.EventFailReason.Exception:
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Origin.Tell(_translationLookup["SERVER_ERROR_COMMAND_INGAME"]);
|
2019-05-08 21:34:17 -04:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Origin.Tell(_translationLookup["COMMANDS_BAN_FAIL"].FormatExt(E.Target.Name));
|
2019-05-08 21:34:17 -04:00
|
|
|
|
break;
|
|
|
|
|
}
|
2015-03-08 17:20:10 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-26 19:06:50 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Unbans a banned client
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class UnbanCommand : Command
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
public UnbanCommand(CommandConfiguration config, ITranslationLookup translationLookup) : base(config, translationLookup)
|
|
|
|
|
{
|
|
|
|
|
Name = "unban";
|
|
|
|
|
Description = _translationLookup["COMMANDS_UNBAN_DESC"];
|
|
|
|
|
Alias = "ub";
|
|
|
|
|
Permission = Permission.SeniorAdmin;
|
|
|
|
|
RequiresTarget = true;
|
|
|
|
|
Arguments = new[]
|
|
|
|
|
{
|
|
|
|
|
new CommandArgument()
|
2017-11-15 16:04:13 -05:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
Name = _translationLookup["COMMANDS_ARGS_CLIENTID"],
|
|
|
|
|
Required = true,
|
|
|
|
|
},
|
|
|
|
|
new CommandArgument()
|
|
|
|
|
{
|
|
|
|
|
Name = _translationLookup["COMMANDS_ARGS_REASON"],
|
|
|
|
|
Required = true
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
2015-03-08 17:20:10 -04:00
|
|
|
|
|
2018-04-13 02:32:30 -04:00
|
|
|
|
public override async Task ExecuteAsync(GameEvent E)
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2019-05-08 21:34:17 -04:00
|
|
|
|
// todo: don't do the lookup here
|
2018-02-17 01:13:38 -05:00
|
|
|
|
var penalties = await E.Owner.Manager.GetPenaltyService().GetActivePenaltiesAsync(E.Target.AliasLinkId);
|
2019-05-29 17:55:35 -04:00
|
|
|
|
if (penalties.Where(p => p.Type == EFPenalty.PenaltyType.Ban || p.Type == EFPenalty.PenaltyType.TempBan).FirstOrDefault() != null)
|
2018-02-17 01:13:38 -05:00
|
|
|
|
{
|
2019-05-08 21:34:17 -04:00
|
|
|
|
switch ((await E.Target.Unban(E.Data, E.Origin).WaitAsync(Utilities.DefaultCommandTimeout, E.Owner.Manager.CancellationToken)).FailReason)
|
|
|
|
|
{
|
|
|
|
|
case GameEvent.EventFailReason.None:
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Origin.Tell(_translationLookup["COMMANDS_UNBAN_SUCCESS"].FormatExt(E.Target));
|
2019-05-08 21:34:17 -04:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Origin.Tell(_translationLookup["SERVER_ERROR_COMMAND_INGAME"]);
|
2019-05-08 21:34:17 -04:00
|
|
|
|
break;
|
|
|
|
|
}
|
2018-02-17 01:13:38 -05:00
|
|
|
|
}
|
2019-05-08 21:34:17 -04:00
|
|
|
|
|
2018-02-17 01:13:38 -05:00
|
|
|
|
else
|
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Origin.Tell(_translationLookup["COMMANDS_UNBAN_FAIL"].FormatExt(E.Target));
|
2018-02-17 01:13:38 -05:00
|
|
|
|
}
|
2015-03-08 17:20:10 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-26 19:06:50 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Prints client information
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class WhoAmICommand : Command
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
public WhoAmICommand(CommandConfiguration config, ITranslationLookup translationLookup) : base(config, translationLookup)
|
|
|
|
|
{
|
|
|
|
|
Name = "whoami";
|
|
|
|
|
Description = _translationLookup["COMMANDS_WHO_DESC"];
|
|
|
|
|
Alias = "who";
|
|
|
|
|
Permission = Permission.User;
|
|
|
|
|
RequiresTarget = false;
|
|
|
|
|
}
|
2015-03-08 17:20:10 -04:00
|
|
|
|
|
2018-09-29 15:52:22 -04:00
|
|
|
|
public override Task ExecuteAsync(GameEvent E)
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
string you = string.Format("{0} [^3#{1}^7] {2} ^7[^3@{3}^7] ^7[{4}^7] IP: {5}", E.Origin.Name, E.Origin.ClientNumber, E.Origin.NetworkId, E.Origin.ClientId, Utilities.ConvertLevelToColor(E.Origin.Level, E.Origin.ClientPermission.Name), E.Origin.IPAddressString);
|
|
|
|
|
E.Origin.Tell(you);
|
2018-09-29 15:52:22 -04:00
|
|
|
|
|
|
|
|
|
return Task.CompletedTask;
|
2015-03-08 17:20:10 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-26 19:06:50 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// List online clients
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class ListClientsCommand : Command
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
public ListClientsCommand(CommandConfiguration config, ITranslationLookup translationLookup) : base(config, translationLookup)
|
|
|
|
|
{
|
|
|
|
|
Name = "list";
|
|
|
|
|
Description = _translationLookup["COMMANDS_LIST_DESC"];
|
|
|
|
|
Alias = "l";
|
|
|
|
|
Permission = Permission.Moderator;
|
|
|
|
|
RequiresTarget = false;
|
|
|
|
|
}
|
2015-03-08 17:20:10 -04:00
|
|
|
|
|
2018-09-29 15:52:22 -04:00
|
|
|
|
public override Task ExecuteAsync(GameEvent E)
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2015-08-26 01:49:47 -04:00
|
|
|
|
StringBuilder playerList = new StringBuilder();
|
2017-05-26 18:49:27 -04:00
|
|
|
|
int count = 0;
|
2018-11-05 22:01:29 -05:00
|
|
|
|
for (int i = 0; i < E.Owner.Clients.Count; i++)
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2018-11-05 22:01:29 -05:00
|
|
|
|
var P = E.Owner.Clients[i];
|
2015-03-11 00:47:34 -04:00
|
|
|
|
|
2017-05-26 18:49:27 -04:00
|
|
|
|
if (P == null)
|
2018-11-05 22:01:29 -05:00
|
|
|
|
{
|
2017-05-26 18:49:27 -04:00
|
|
|
|
continue;
|
2018-11-05 22:01:29 -05:00
|
|
|
|
}
|
2018-08-03 22:11:58 -04:00
|
|
|
|
// todo: fix spacing
|
2018-09-07 23:29:42 -04:00
|
|
|
|
// todo: make this better :)
|
2017-05-26 18:49:27 -04:00
|
|
|
|
if (P.Masked)
|
2018-11-05 22:01:29 -05:00
|
|
|
|
{
|
2019-03-24 22:34:20 -04:00
|
|
|
|
playerList.AppendFormat("[^3{0}^7]{3}[^3{1}^7] {2}", Utilities.ConvertLevelToColor(EFClient.Permission.User, P.ClientPermission.Name), P.ClientNumber, P.Name, Utilities.GetSpaces(EFClient.Permission.SeniorAdmin.ToString().Length - EFClient.Permission.User.ToString().Length));
|
2018-11-05 22:01:29 -05:00
|
|
|
|
}
|
2017-05-26 18:49:27 -04:00
|
|
|
|
else
|
2018-11-05 22:01:29 -05:00
|
|
|
|
{
|
2019-03-24 22:34:20 -04:00
|
|
|
|
playerList.AppendFormat("[^3{0}^7]{3}[^3{1}^7] {2}", Utilities.ConvertLevelToColor(P.Level, P.ClientPermission.Name), P.ClientNumber, P.Name, Utilities.GetSpaces(EFClient.Permission.SeniorAdmin.ToString().Length - P.Level.ToString().Length));
|
2018-11-05 22:01:29 -05:00
|
|
|
|
}
|
2015-08-26 01:49:47 -04:00
|
|
|
|
|
2018-11-05 22:01:29 -05:00
|
|
|
|
if (count == 2 || E.Owner.GetClientsAsList().Count == 1)
|
2017-05-26 18:49:27 -04:00
|
|
|
|
{
|
2018-09-29 15:52:22 -04:00
|
|
|
|
E.Origin.Tell(playerList.ToString());
|
2017-05-26 18:49:27 -04:00
|
|
|
|
count = 0;
|
|
|
|
|
playerList = new StringBuilder();
|
|
|
|
|
continue;
|
2015-07-15 17:11:29 -04:00
|
|
|
|
}
|
2017-05-26 18:49:27 -04:00
|
|
|
|
|
|
|
|
|
count++;
|
2015-03-08 17:20:10 -04:00
|
|
|
|
}
|
2018-09-07 23:29:42 -04:00
|
|
|
|
|
|
|
|
|
if (playerList.Length > 0)
|
|
|
|
|
{
|
2018-09-29 15:52:22 -04:00
|
|
|
|
E.Origin.Tell(playerList.ToString());
|
2018-09-07 23:29:42 -04:00
|
|
|
|
}
|
2018-09-29 15:52:22 -04:00
|
|
|
|
|
|
|
|
|
// todo: make no players response for webfront
|
|
|
|
|
|
|
|
|
|
return Task.CompletedTask;
|
2015-03-08 17:20:10 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-26 19:06:50 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Prints help information
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class HelpCommand : Command
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
public HelpCommand(CommandConfiguration config, ITranslationLookup translationLookup) : base(config, translationLookup)
|
|
|
|
|
{
|
|
|
|
|
Name = "help";
|
|
|
|
|
Description = _translationLookup["COMMANDS_HELP_DESC"];
|
|
|
|
|
Alias = "h";
|
|
|
|
|
Permission = Permission.User;
|
|
|
|
|
RequiresTarget = false;
|
|
|
|
|
Arguments = new[]
|
|
|
|
|
{
|
|
|
|
|
new CommandArgument()
|
2017-11-15 16:04:13 -05:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
Name = _translationLookup["COMMANDS_ARGS_COMMANDS"],
|
|
|
|
|
Required = false
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
2015-03-08 17:20:10 -04:00
|
|
|
|
|
2018-09-29 15:52:22 -04:00
|
|
|
|
public override Task ExecuteAsync(GameEvent E)
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2020-02-11 17:44:06 -05:00
|
|
|
|
string cmd = E.Data.Trim();
|
2015-03-08 17:20:10 -04:00
|
|
|
|
|
|
|
|
|
if (cmd.Length > 2)
|
|
|
|
|
{
|
|
|
|
|
bool found = false;
|
2020-02-11 17:44:06 -05:00
|
|
|
|
foreach (var command in E.Owner.Manager.GetCommands())
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2020-02-11 17:44:06 -05:00
|
|
|
|
if (command.Name == cmd.ToLower() ||
|
|
|
|
|
command.Alias == cmd.ToLower())
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2020-02-11 17:44:06 -05:00
|
|
|
|
E.Origin.Tell($"[^3{command.Name}^7] {command.Description}");
|
|
|
|
|
E.Origin.Tell(command.Syntax);
|
2015-03-08 17:20:10 -04:00
|
|
|
|
found = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!found)
|
2018-09-29 15:52:22 -04:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Origin.Tell(_translationLookup["COMMANDS_HELP_NOTFOUND"]);
|
2018-09-29 15:52:22 -04:00
|
|
|
|
}
|
2015-03-08 17:20:10 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
{
|
2015-03-11 00:47:34 -04:00
|
|
|
|
int count = 0;
|
2015-08-22 12:41:14 -04:00
|
|
|
|
StringBuilder helpResponse = new StringBuilder();
|
2017-09-29 22:42:24 -04:00
|
|
|
|
var CommandList = E.Owner.Manager.GetCommands();
|
2015-03-11 00:47:34 -04:00
|
|
|
|
|
2017-05-26 18:49:27 -04:00
|
|
|
|
foreach (Command C in CommandList)
|
2017-08-17 19:28:08 -04:00
|
|
|
|
{
|
2015-08-20 01:06:44 -04:00
|
|
|
|
if (E.Origin.Level >= C.Permission)
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2015-08-22 12:41:14 -04:00
|
|
|
|
helpResponse.Append(" [^3" + C.Name + "^7] ");
|
2015-04-10 00:02:12 -04:00
|
|
|
|
if (count >= 4)
|
2015-03-11 00:47:34 -04:00
|
|
|
|
{
|
2018-09-29 15:52:22 -04:00
|
|
|
|
E.Origin.Tell(helpResponse.ToString());
|
2015-08-22 12:41:14 -04:00
|
|
|
|
helpResponse = new StringBuilder();
|
2015-03-11 00:47:34 -04:00
|
|
|
|
count = 0;
|
|
|
|
|
}
|
|
|
|
|
count++;
|
2015-03-08 17:20:10 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-09-29 15:52:22 -04:00
|
|
|
|
E.Origin.Tell(helpResponse.ToString());
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Origin.Tell(_translationLookup["COMMANDS_HELP_MOREINFO"]);
|
2015-03-08 17:20:10 -04:00
|
|
|
|
}
|
2018-09-29 15:52:22 -04:00
|
|
|
|
|
|
|
|
|
return Task.CompletedTask;
|
2015-03-08 17:20:10 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-26 19:06:50 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Fast restarts the map
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class FastRestartCommand : Command
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
public FastRestartCommand(CommandConfiguration config, ITranslationLookup translationLookup) : base(config, translationLookup)
|
|
|
|
|
{
|
|
|
|
|
Name = "fastrestart";
|
|
|
|
|
Description = _translationLookup["COMMANDS_FASTRESTART_DESC"];
|
|
|
|
|
Alias = "fr";
|
|
|
|
|
Permission = Permission.Moderator;
|
|
|
|
|
RequiresTarget = false;
|
|
|
|
|
}
|
2015-03-08 17:20:10 -04:00
|
|
|
|
|
2018-04-13 02:32:30 -04:00
|
|
|
|
public override async Task ExecuteAsync(GameEvent E)
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2018-02-15 23:01:28 -05:00
|
|
|
|
await E.Owner.ExecuteCommandAsync("fast_restart");
|
|
|
|
|
|
2018-09-29 15:52:22 -04:00
|
|
|
|
var _ = !E.Origin.Masked ?
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Owner.Broadcast($"^5{E.Origin.Name} ^7{_translationLookup["COMMANDS_FASTRESTART_UNMASKED"]}") :
|
|
|
|
|
E.Owner.Broadcast(_translationLookup["COMMANDS_FASTRESTART_MASKED"]);
|
2015-03-08 17:20:10 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-26 19:06:50 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Cycles to the next map in rotation
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class MapRotateCommand : Command
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
public MapRotateCommand(CommandConfiguration config, ITranslationLookup translationLookup) : base(config, translationLookup)
|
|
|
|
|
{
|
|
|
|
|
Name = "maprotate";
|
|
|
|
|
Description = _translationLookup["COMMANDS_MAPROTATE_DESC"];
|
|
|
|
|
Alias = "mr";
|
|
|
|
|
Permission = Permission.Administrator;
|
|
|
|
|
RequiresTarget = false;
|
|
|
|
|
}
|
2015-03-08 17:20:10 -04:00
|
|
|
|
|
2018-04-13 02:32:30 -04:00
|
|
|
|
public override async Task ExecuteAsync(GameEvent E)
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2018-09-29 15:52:22 -04:00
|
|
|
|
var _ = !E.Origin.Masked ?
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Owner.Broadcast($"{_translationLookup["COMMANDS_MAPROTATE"]} [^5{E.Origin.Name}^7]", E.Origin) :
|
|
|
|
|
E.Owner.Broadcast(_translationLookup["COMMANDS_MAPROTATE"], E.Origin);
|
2018-09-29 15:52:22 -04:00
|
|
|
|
|
2018-05-14 13:55:10 -04:00
|
|
|
|
await Task.Delay(5000);
|
2017-05-26 18:49:27 -04:00
|
|
|
|
await E.Owner.ExecuteCommandAsync("map_rotate");
|
2015-03-08 17:20:10 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-26 19:06:50 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Sets the level of given client
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class SetLevelCommand : Command
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2020-05-16 12:54:01 -04:00
|
|
|
|
public SetLevelCommand(CommandConfiguration config, ITranslationLookup translationLookup, ILogger logger) : base(config, translationLookup)
|
2020-01-26 19:06:50 -05:00
|
|
|
|
{
|
|
|
|
|
Name = "setlevel";
|
|
|
|
|
Description = _translationLookup["COMMANDS_SETLEVEL_DESC"];
|
|
|
|
|
Alias = "sl";
|
|
|
|
|
Permission = Permission.Moderator;
|
|
|
|
|
RequiresTarget = true;
|
|
|
|
|
Arguments = new[]
|
|
|
|
|
{
|
|
|
|
|
new CommandArgument()
|
|
|
|
|
{
|
|
|
|
|
Name = _translationLookup["COMMANDS_ARGS_PLAYER"],
|
|
|
|
|
Required = true
|
|
|
|
|
},
|
|
|
|
|
new CommandArgument()
|
|
|
|
|
{
|
|
|
|
|
Name = _translationLookup["COMMANDS_ARGS_LEVEL"],
|
|
|
|
|
Required = true
|
|
|
|
|
}
|
|
|
|
|
};
|
2020-05-16 12:54:01 -04:00
|
|
|
|
this.logger = logger;
|
2020-01-26 19:06:50 -05:00
|
|
|
|
}
|
2015-03-08 17:20:10 -04:00
|
|
|
|
|
2020-05-16 12:54:01 -04:00
|
|
|
|
public override async Task ExecuteAsync(GameEvent gameEvent)
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2020-05-16 12:54:01 -04:00
|
|
|
|
Permission oldPerm = gameEvent.Target.Level;
|
|
|
|
|
Permission newPerm = Utilities.MatchPermission(gameEvent.Data);
|
|
|
|
|
bool allowMultiOwner = gameEvent.Owner.Manager.GetApplicationSettings().Configuration().EnableMultipleOwners;
|
|
|
|
|
bool steppedPrivileges = gameEvent.Owner.Manager.GetApplicationSettings().Configuration().EnableSteppedHierarchy;
|
|
|
|
|
var targetClient = gameEvent.Target;
|
|
|
|
|
|
|
|
|
|
// pre setup logic
|
|
|
|
|
bool canPromoteSteppedPriv = gameEvent.Origin.Level > newPerm || gameEvent.Origin.Level == Permission.Owner;
|
|
|
|
|
bool hasOwner = await gameEvent.Owner.Manager.GetClientService().GetOwnerCount() > 0;
|
|
|
|
|
|
|
|
|
|
// trying to set self
|
|
|
|
|
if (gameEvent.Target == gameEvent.Origin)
|
|
|
|
|
{
|
|
|
|
|
gameEvent.Origin.Tell(_translationLookup["COMMANDS_SETLEVEL_SELF"]);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2019-03-24 22:34:20 -04:00
|
|
|
|
|
2020-05-16 12:54:01 -04:00
|
|
|
|
// origin permission not high enough
|
|
|
|
|
else if (gameEvent.Origin.Level < gameEvent.Target.Level)
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2020-05-16 12:54:01 -04:00
|
|
|
|
gameEvent.Origin.Tell(_translationLookup["COMMANDS_SETLEVEL_PERMISSION"].FormatExt(gameEvent.Target.Name));
|
2019-08-18 12:18:20 -04:00
|
|
|
|
return;
|
2015-03-08 17:20:10 -04:00
|
|
|
|
}
|
|
|
|
|
|
2020-05-16 12:54:01 -04:00
|
|
|
|
// trying to set owner without enabling multiple owners
|
|
|
|
|
else if (newPerm == Permission.Owner && !allowMultiOwner && hasOwner)
|
2017-06-19 13:58:01 -04:00
|
|
|
|
{
|
2019-03-24 22:34:20 -04:00
|
|
|
|
// only one owner is allowed
|
2020-05-16 12:54:01 -04:00
|
|
|
|
gameEvent.Origin.Tell(_translationLookup["COMMANDS_SETLEVEL_OWNER"]);
|
2019-08-18 12:18:20 -04:00
|
|
|
|
return;
|
2017-06-19 13:58:01 -04:00
|
|
|
|
}
|
|
|
|
|
|
2020-05-16 12:54:01 -04:00
|
|
|
|
// trying to set level when only owner is allowed to
|
|
|
|
|
else if (gameEvent.Origin.Level < Permission.Owner && !steppedPrivileges)
|
2018-03-24 17:35:54 -04:00
|
|
|
|
{
|
2019-03-24 22:34:20 -04:00
|
|
|
|
// only the owner is allowed to set levels
|
2020-05-16 12:54:01 -04:00
|
|
|
|
gameEvent.Origin.Tell($"{_translationLookup["COMMANDS_SETLEVEL_STEPPEDDISABLED"]} ^5{gameEvent.Target.Name}");
|
2019-08-18 12:18:20 -04:00
|
|
|
|
return;
|
2018-03-24 17:35:54 -04:00
|
|
|
|
}
|
|
|
|
|
|
2020-05-16 12:54:01 -04:00
|
|
|
|
// stepped privilege is enabled, but the new level is too high
|
|
|
|
|
else if (steppedPrivileges && !canPromoteSteppedPriv)
|
2018-03-24 17:35:54 -04:00
|
|
|
|
{
|
2019-03-24 22:34:20 -04:00
|
|
|
|
// can't promote a client to higher than your current perms
|
2019-08-08 16:58:23 -04:00
|
|
|
|
// or your peer
|
2020-05-16 12:54:01 -04:00
|
|
|
|
gameEvent.Origin.Tell(string.Format(_translationLookup["COMMANDS_SETLEVEL_LEVELTOOHIGH"], gameEvent.Target.Name, (gameEvent.Origin.Level - 1).ToString()));
|
2019-08-18 12:18:20 -04:00
|
|
|
|
return;
|
2018-03-24 17:35:54 -04:00
|
|
|
|
}
|
|
|
|
|
|
2020-05-16 12:54:01 -04:00
|
|
|
|
// valid
|
2019-08-08 16:58:23 -04:00
|
|
|
|
else if (newPerm > Permission.Banned)
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2020-05-16 12:54:01 -04:00
|
|
|
|
targetClient = targetClient.ClientNumber < 0 ?
|
|
|
|
|
gameEvent.Owner.Manager.GetActiveClients()
|
|
|
|
|
.FirstOrDefault(c => c.ClientId == targetClient?.ClientId) ?? targetClient : targetClient;
|
2017-06-12 13:50:00 -04:00
|
|
|
|
|
2020-05-16 12:54:01 -04:00
|
|
|
|
logger.WriteInfo($"Beginning set level of client {gameEvent.Origin} to {newPerm}");
|
2018-10-15 20:51:04 -04:00
|
|
|
|
|
2020-05-16 12:54:01 -04:00
|
|
|
|
var result = await targetClient.SetLevel(newPerm, gameEvent.Origin).WaitAsync(Utilities.DefaultCommandTimeout, gameEvent.Owner.Manager.CancellationToken);
|
|
|
|
|
|
|
|
|
|
if (result.Failed)
|
|
|
|
|
{
|
|
|
|
|
logger.WriteInfo($"Failed to set level of client {gameEvent.Origin}");
|
|
|
|
|
gameEvent.Origin.Tell(_translationLookup["SERVER_ERROR_COMMAND_INGAME"]);
|
|
|
|
|
return;
|
2018-02-24 00:56:03 -05:00
|
|
|
|
}
|
|
|
|
|
|
2020-05-16 12:54:01 -04:00
|
|
|
|
// inform the client that they were promoted
|
|
|
|
|
// we don't really want to tell them if they're demoted haha
|
|
|
|
|
if (targetClient.IsIngame && newPerm > oldPerm)
|
2018-02-24 00:56:03 -05:00
|
|
|
|
{
|
2020-05-16 12:54:01 -04:00
|
|
|
|
targetClient.Tell(_translationLookup["COMMANDS_SETLEVEL_SUCCESS_TARGET"].FormatExt(newPerm));
|
2018-02-24 00:56:03 -05:00
|
|
|
|
}
|
2017-06-19 13:58:01 -04:00
|
|
|
|
|
2019-03-24 22:34:20 -04:00
|
|
|
|
// inform the origin that the client has been updated
|
|
|
|
|
_ = newPerm < oldPerm ?
|
2020-05-16 12:54:01 -04:00
|
|
|
|
gameEvent.Origin.Tell(_translationLookup["COMMANDS_SETLEVEL_DEMOTE_SUCCESS"].FormatExt(targetClient.Name)) :
|
|
|
|
|
gameEvent.Origin.Tell(_translationLookup["COMMANDS_SETLEVEL_SUCCESS"].FormatExt(targetClient.Name));
|
2015-03-08 17:20:10 -04:00
|
|
|
|
}
|
|
|
|
|
|
2020-05-16 12:54:01 -04:00
|
|
|
|
// all other tests failed so it's invalid group
|
2015-03-08 17:20:10 -04:00
|
|
|
|
else
|
2018-09-29 15:52:22 -04:00
|
|
|
|
{
|
2020-05-16 12:54:01 -04:00
|
|
|
|
gameEvent.Origin.Tell(_translationLookup["COMMANDS_SETLEVEL_FAIL"]);
|
2018-09-29 15:52:22 -04:00
|
|
|
|
}
|
2015-03-08 17:20:10 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-26 19:06:50 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Prints the amount of memory IW4MAdmin is using
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class MemoryUsageCommand : Command
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
public MemoryUsageCommand(CommandConfiguration config, ITranslationLookup translationLookup) : base(config, translationLookup)
|
|
|
|
|
{
|
|
|
|
|
Name = "usage";
|
|
|
|
|
Description = _translationLookup["COMMANDS_USAGE_DESC"];
|
|
|
|
|
Alias = "us";
|
|
|
|
|
Permission = Permission.Moderator;
|
|
|
|
|
RequiresTarget = false;
|
|
|
|
|
}
|
2015-03-08 17:20:10 -04:00
|
|
|
|
|
2018-09-29 15:52:22 -04:00
|
|
|
|
public override Task ExecuteAsync(GameEvent E)
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Origin.Tell(_translationLookup["COMMANDS_USAGE_TEXT"].FormatExt(Math.Round(((System.Diagnostics.Process.GetCurrentProcess().PrivateMemorySize64 / 2048f) / 1200f), 1)));
|
2018-09-29 15:52:22 -04:00
|
|
|
|
return Task.CompletedTask;
|
2015-03-08 17:20:10 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-26 19:06:50 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Prints out how long IW4MAdmin has been running
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class UptimeCommand : Command
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
public UptimeCommand(CommandConfiguration config, ITranslationLookup translationLookup) : base(config, translationLookup)
|
|
|
|
|
{
|
|
|
|
|
Name = "uptime";
|
|
|
|
|
Description = _translationLookup["COMMANDS_UPTIME_DESC"];
|
|
|
|
|
Alias = "up";
|
|
|
|
|
Permission = Permission.Moderator;
|
|
|
|
|
RequiresTarget = false;
|
|
|
|
|
}
|
2015-03-08 17:20:10 -04:00
|
|
|
|
|
2018-09-29 15:52:22 -04:00
|
|
|
|
public override Task ExecuteAsync(GameEvent E)
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
|
|
|
|
TimeSpan uptime = DateTime.Now - System.Diagnostics.Process.GetCurrentProcess().StartTime;
|
2020-01-26 19:06:50 -05:00
|
|
|
|
var loc = _translationLookup;
|
2019-04-09 16:02:49 -04:00
|
|
|
|
E.Origin.Tell(loc["COMMANDS_UPTIME_TEXT"].FormatExt(uptime.Days, uptime.Hours, uptime.Minutes));
|
2018-09-29 15:52:22 -04:00
|
|
|
|
return Task.CompletedTask;
|
2015-03-08 17:20:10 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-26 19:06:50 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Lists all unmasked admins
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class ListAdminsCommand : Command
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2020-07-31 21:40:03 -04:00
|
|
|
|
private readonly CommandConfiguration _config;
|
|
|
|
|
|
2020-01-26 19:06:50 -05:00
|
|
|
|
public ListAdminsCommand(CommandConfiguration config, ITranslationLookup translationLookup) : base(config, translationLookup)
|
|
|
|
|
{
|
|
|
|
|
Name = "admins";
|
|
|
|
|
Description = _translationLookup["COMMANDS_ADMINS_DESC"];
|
|
|
|
|
Alias = "a";
|
|
|
|
|
Permission = Permission.User;
|
|
|
|
|
RequiresTarget = false;
|
2020-07-31 21:40:03 -04:00
|
|
|
|
|
|
|
|
|
_config = config;
|
2020-01-26 19:06:50 -05:00
|
|
|
|
}
|
2015-03-08 17:20:10 -04:00
|
|
|
|
|
2020-01-26 19:06:50 -05:00
|
|
|
|
public static string OnlineAdmins(Server S, ITranslationLookup lookup)
|
2018-06-26 21:17:24 -04:00
|
|
|
|
{
|
2018-11-05 22:01:29 -05:00
|
|
|
|
var onlineAdmins = S.GetClientsAsList()
|
2020-01-26 19:06:50 -05:00
|
|
|
|
.Where(p => p.Level > Permission.Flagged)
|
2018-06-26 21:17:24 -04:00
|
|
|
|
.Where(p => !p.Masked)
|
2018-08-03 22:11:58 -04:00
|
|
|
|
.Select(p => $"[^3{Utilities.ConvertLevelToColor(p.Level, p.ClientPermission.Name)}^7] {p.Name}");
|
2018-06-26 21:17:24 -04:00
|
|
|
|
|
|
|
|
|
return onlineAdmins.Count() > 0 ?
|
|
|
|
|
string.Join(Environment.NewLine, onlineAdmins) :
|
2020-01-26 19:06:50 -05:00
|
|
|
|
lookup["COMMANDS_ADMINS_NONE"];
|
2018-06-26 21:17:24 -04:00
|
|
|
|
}
|
|
|
|
|
|
2018-09-29 15:52:22 -04:00
|
|
|
|
public override Task ExecuteAsync(GameEvent E)
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
foreach (string line in OnlineAdmins(E.Owner, _translationLookup).Split(Environment.NewLine))
|
2017-05-27 00:22:50 -04:00
|
|
|
|
{
|
2020-07-31 21:40:03 -04:00
|
|
|
|
var _ = E.Message.IsBroadcastCommand(_config.BroadcastCommandPrefix) ? E.Owner.Broadcast(line) : E.Origin.Tell(line);
|
2017-05-27 00:22:50 -04:00
|
|
|
|
}
|
2018-09-29 15:52:22 -04:00
|
|
|
|
|
|
|
|
|
return Task.CompletedTask;
|
2015-03-08 17:20:10 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-26 19:06:50 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Attempts to load the specified map
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class LoadMapCommand : Command
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
public LoadMapCommand(CommandConfiguration config, ITranslationLookup translationLookup) : base(config, translationLookup)
|
|
|
|
|
{
|
|
|
|
|
Name = "map";
|
|
|
|
|
Description = _translationLookup["COMMANDS_MAP_DESC"];
|
|
|
|
|
Alias = "m";
|
|
|
|
|
Permission = Permission.Administrator;
|
|
|
|
|
RequiresTarget = false;
|
|
|
|
|
Arguments = new[]
|
2017-11-15 16:04:13 -05:00
|
|
|
|
{
|
|
|
|
|
new CommandArgument()
|
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
Name = _translationLookup["COMMANDS_ARGS_MAP"],
|
2017-11-15 16:04:13 -05:00
|
|
|
|
Required = true
|
|
|
|
|
}
|
2020-01-26 19:06:50 -05:00
|
|
|
|
};
|
|
|
|
|
}
|
2015-03-08 17:20:10 -04:00
|
|
|
|
|
2018-04-13 02:32:30 -04:00
|
|
|
|
public override async Task ExecuteAsync(GameEvent E)
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
|
|
|
|
string newMap = E.Data.Trim().ToLower();
|
2017-06-19 13:58:01 -04:00
|
|
|
|
foreach (Map m in E.Owner.Maps)
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
|
|
|
|
if (m.Name.ToLower() == newMap || m.Alias.ToLower() == newMap)
|
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Owner.Broadcast(_translationLookup["COMMANDS_MAP_SUCCESS"].FormatExt(m.Alias));
|
2019-05-08 21:34:17 -04:00
|
|
|
|
await Task.Delay((int)(Utilities.DefaultCommandTimeout.TotalMilliseconds / 2.0));
|
2017-05-26 18:49:27 -04:00
|
|
|
|
await E.Owner.LoadMap(m.Name);
|
2015-03-08 17:20:10 -04:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-08 21:34:17 -04:00
|
|
|
|
// todo: this can be moved into a single statement
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Owner.Broadcast(_translationLookup["COMMANDS_MAP_UKN"].FormatExt(newMap));
|
2018-05-14 13:55:10 -04:00
|
|
|
|
await Task.Delay(5000);
|
2017-05-26 18:49:27 -04:00
|
|
|
|
await E.Owner.LoadMap(newMap);
|
2015-03-08 17:20:10 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-26 19:06:50 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Finds player by name
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class FindPlayerCommand : Command
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
public FindPlayerCommand(CommandConfiguration config, ITranslationLookup translationLookup) : base(config, translationLookup)
|
|
|
|
|
{
|
|
|
|
|
Name = "find";
|
|
|
|
|
Description = _translationLookup["COMMANDS_FIND_DESC"];
|
|
|
|
|
Alias = "f";
|
|
|
|
|
Permission = Permission.Administrator;
|
|
|
|
|
RequiresTarget = false;
|
|
|
|
|
Arguments = new[]
|
2017-11-15 16:04:13 -05:00
|
|
|
|
{
|
|
|
|
|
new CommandArgument()
|
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
Name = _translationLookup["COMMANDS_ARGS_PLAYER"],
|
2017-11-15 16:04:13 -05:00
|
|
|
|
Required = true
|
|
|
|
|
}
|
2020-01-26 19:06:50 -05:00
|
|
|
|
};
|
|
|
|
|
}
|
2015-03-08 17:20:10 -04:00
|
|
|
|
|
2018-04-13 02:32:30 -04:00
|
|
|
|
public override async Task ExecuteAsync(GameEvent E)
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2018-04-21 18:18:20 -04:00
|
|
|
|
if (E.Data.Length < 3)
|
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Origin.Tell(_translationLookup["COMMANDS_FIND_MIN"]);
|
2018-04-21 18:18:20 -04:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-25 22:05:35 -04:00
|
|
|
|
var db_players = (await (E.Owner.Manager.GetClientService() as ClientService).FindClientsByIdentifier(E.Data));
|
2015-03-23 23:01:05 -04:00
|
|
|
|
|
2017-11-25 20:29:58 -05:00
|
|
|
|
if (db_players.Count == 0)
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Origin.Tell(_translationLookup["COMMANDS_FIND_EMPTY"]);
|
2015-03-08 17:20:10 -04:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-11 20:17:20 -05:00
|
|
|
|
foreach (var P in db_players)
|
2017-08-17 19:28:08 -04:00
|
|
|
|
{
|
2018-02-11 20:17:20 -05:00
|
|
|
|
// they're not going by another alias
|
2019-04-25 22:05:35 -04:00
|
|
|
|
// /*P.AliasLink.Children.FirstOrDefault(a => a.Name.ToLower().Contains(E.Data.ToLower()))?.Name*/
|
2018-02-11 20:17:20 -05:00
|
|
|
|
string msg = P.Name.ToLower().Contains(E.Data.ToLower()) ?
|
2019-04-25 22:05:35 -04:00
|
|
|
|
$"[^3{P.Name}^7] [^3@{P.ClientId}^7] - [{ Utilities.ConvertLevelToColor((Permission)P.LevelInt, P.Level)}^7] - {P.IPAddress} | last seen {Utilities.GetTimePassed(P.LastConnection)}" :
|
|
|
|
|
$"()->[^3{P.Name}^7] [^3@{P.ClientId}^7] - [{ Utilities.ConvertLevelToColor((Permission)P.LevelInt, P.Level)}^7] - {P.IPAddress} | last seen {Utilities.GetTimePassed(P.LastConnection)}";
|
2018-09-29 15:52:22 -04:00
|
|
|
|
E.Origin.Tell(msg);
|
2015-03-08 17:20:10 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-26 19:06:50 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Lists server and global rules
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class ListRulesCommands : Command
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2020-07-31 21:40:03 -04:00
|
|
|
|
private readonly CommandConfiguration _config;
|
|
|
|
|
|
2020-01-26 19:06:50 -05:00
|
|
|
|
public ListRulesCommands(CommandConfiguration config, ITranslationLookup translationLookup) : base(config, translationLookup)
|
|
|
|
|
{
|
|
|
|
|
Name = "rules";
|
|
|
|
|
Description = _translationLookup["COMMANDS_RULES_DESC"];
|
|
|
|
|
Alias = "r";
|
|
|
|
|
Permission = Permission.User;
|
|
|
|
|
RequiresTarget = false;
|
2020-07-31 21:40:03 -04:00
|
|
|
|
|
|
|
|
|
_config = config;
|
2020-01-26 19:06:50 -05:00
|
|
|
|
}
|
2015-03-08 17:20:10 -04:00
|
|
|
|
|
2018-09-29 15:52:22 -04:00
|
|
|
|
public override Task ExecuteAsync(GameEvent E)
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2020-01-17 18:31:53 -05:00
|
|
|
|
if (E.Owner.Manager.GetApplicationSettings().Configuration().GlobalRules?.Length < 1 &&
|
|
|
|
|
E.Owner.ServerConfig.Rules?.Length < 1)
|
2017-05-31 01:31:56 -04:00
|
|
|
|
{
|
2020-07-31 21:40:03 -04:00
|
|
|
|
var _ = E.Message.IsBroadcastCommand(_config.BroadcastCommandPrefix) ?
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Owner.Broadcast(_translationLookup["COMMANDS_RULES_NONE"]) :
|
|
|
|
|
E.Origin.Tell(_translationLookup["COMMANDS_RULES_NONE"]);
|
2017-05-31 01:31:56 -04:00
|
|
|
|
}
|
|
|
|
|
|
2015-03-08 17:20:10 -04:00
|
|
|
|
else
|
|
|
|
|
{
|
2018-03-18 22:25:11 -04:00
|
|
|
|
var rules = new List<string>();
|
|
|
|
|
rules.AddRange(E.Owner.Manager.GetApplicationSettings().Configuration().GlobalRules);
|
|
|
|
|
if (E.Owner.ServerConfig.Rules != null)
|
2018-11-05 22:01:29 -05:00
|
|
|
|
{
|
2018-03-18 22:25:11 -04:00
|
|
|
|
rules.AddRange(E.Owner.ServerConfig.Rules);
|
2018-11-05 22:01:29 -05:00
|
|
|
|
}
|
2018-03-18 22:25:11 -04:00
|
|
|
|
|
|
|
|
|
foreach (string r in rules)
|
2017-05-31 01:31:56 -04:00
|
|
|
|
{
|
2020-07-31 21:40:03 -04:00
|
|
|
|
var _ = E.Message.IsBroadcastCommand(_config.BroadcastCommandPrefix) ? E.Owner.Broadcast($"- {r}") : E.Origin.Tell($"- {r}");
|
2017-05-31 01:31:56 -04:00
|
|
|
|
}
|
2015-03-08 17:20:10 -04:00
|
|
|
|
}
|
2018-09-29 15:52:22 -04:00
|
|
|
|
|
|
|
|
|
return Task.CompletedTask;
|
2015-03-08 17:20:10 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
2015-03-09 16:11:09 -04:00
|
|
|
|
|
2020-01-26 19:06:50 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Sends a private message to another player
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class PrivateMessageCommand : Command
|
2015-03-09 16:11:09 -04:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
public PrivateMessageCommand(CommandConfiguration config, ITranslationLookup translationLookup) : base(config, translationLookup)
|
|
|
|
|
{
|
|
|
|
|
Name = "privatemessage";
|
|
|
|
|
Description = _translationLookup["COMMANDS_PM_DESC"];
|
|
|
|
|
Alias = "pm";
|
|
|
|
|
Permission = Permission.User;
|
|
|
|
|
RequiresTarget = true;
|
|
|
|
|
Arguments = new[]
|
|
|
|
|
{
|
|
|
|
|
new CommandArgument()
|
2017-11-15 16:04:13 -05:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
Name = _translationLookup["COMMANDS_ARGS_PLAYER"],
|
|
|
|
|
Required = true
|
|
|
|
|
},
|
|
|
|
|
new CommandArgument()
|
|
|
|
|
{
|
|
|
|
|
Name = _translationLookup["COMMANDS_ARGS_MESSAGE"],
|
|
|
|
|
Required = true
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
2015-03-09 16:11:09 -04:00
|
|
|
|
|
2018-09-29 15:52:22 -04:00
|
|
|
|
public override Task ExecuteAsync(GameEvent E)
|
2015-03-09 16:11:09 -04:00
|
|
|
|
{
|
2018-09-29 15:52:22 -04:00
|
|
|
|
E.Target.Tell($"^1{E.Origin.Name} ^3[PM]^7 - {E.Data}");
|
|
|
|
|
E.Origin.Tell($"To ^3{E.Target.Name} ^7-> {E.Data}");
|
|
|
|
|
return Task.CompletedTask;
|
2015-03-09 16:11:09 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
2015-03-09 21:28:37 -04:00
|
|
|
|
|
2020-01-26 19:06:50 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Flag given client for specified reason
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class FlagClientCommand : Command
|
2015-03-23 23:01:05 -04:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
public FlagClientCommand(CommandConfiguration config, ITranslationLookup translationLookup) : base(config, translationLookup)
|
|
|
|
|
{
|
|
|
|
|
Name = "flag";
|
|
|
|
|
Description = _translationLookup["COMMANDS_FLAG_DESC"];
|
|
|
|
|
Alias = "fp";
|
|
|
|
|
Permission = Permission.Moderator;
|
|
|
|
|
RequiresTarget = true;
|
|
|
|
|
Arguments = new[]
|
|
|
|
|
{
|
|
|
|
|
new CommandArgument()
|
2017-11-15 16:04:13 -05:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
Name = _translationLookup["COMMANDS_ARGS_PLAYER"],
|
|
|
|
|
Required = true
|
|
|
|
|
},
|
|
|
|
|
new CommandArgument()
|
|
|
|
|
{
|
|
|
|
|
Name = _translationLookup["COMMANDS_ARGS_REASON"],
|
|
|
|
|
Required = true
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
2015-03-23 23:01:05 -04:00
|
|
|
|
|
2019-05-08 21:34:17 -04:00
|
|
|
|
public override async Task ExecuteAsync(GameEvent E)
|
2015-03-23 23:01:05 -04:00
|
|
|
|
{
|
2019-05-08 21:34:17 -04:00
|
|
|
|
switch ((await E.Target.Flag(E.Data, E.Origin).WaitAsync(Utilities.DefaultCommandTimeout, E.Owner.Manager.CancellationToken)).FailReason)
|
2015-03-23 23:01:05 -04:00
|
|
|
|
{
|
2019-05-08 21:34:17 -04:00
|
|
|
|
case GameEvent.EventFailReason.Permission:
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Origin.Tell(_translationLookup["COMMANDS_FLAG_FAIL"].FormatExt(E.Target.Name));
|
2019-05-08 21:34:17 -04:00
|
|
|
|
break;
|
|
|
|
|
case GameEvent.EventFailReason.Invalid:
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Origin.Tell($"{_translationLookup["COMMANDS_FLAG_ALREADYFLAGGED"]}");
|
2019-05-08 21:34:17 -04:00
|
|
|
|
break;
|
|
|
|
|
case GameEvent.EventFailReason.None:
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Origin.Tell(_translationLookup["COMMANDS_FLAG_SUCCESS"].FormatExt(E.Target.Name));
|
2019-05-08 21:34:17 -04:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Origin.Tell(_translationLookup["SERVER_ERROR_COMMAND_INGAME"]);
|
2019-05-08 21:34:17 -04:00
|
|
|
|
break;
|
2015-03-23 23:01:05 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-26 19:06:50 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Unflag given client for specified reason
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class UnflagClientCommand : Command
|
2018-05-08 00:58:46 -04:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
public UnflagClientCommand(CommandConfiguration config, ITranslationLookup translationLookup) : base(config, translationLookup)
|
|
|
|
|
{
|
|
|
|
|
Name = "unflag";
|
|
|
|
|
Description = _translationLookup["COMMANDS_UNFLAG_DESC"];
|
|
|
|
|
Alias = "uf";
|
|
|
|
|
Permission = Permission.Moderator;
|
|
|
|
|
RequiresTarget = true;
|
|
|
|
|
Arguments = new[]
|
|
|
|
|
{
|
|
|
|
|
new CommandArgument()
|
2018-05-08 00:58:46 -04:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
Name = _translationLookup["COMMANDS_ARGS_PLAYER"],
|
|
|
|
|
Required = true
|
|
|
|
|
},
|
|
|
|
|
new CommandArgument()
|
|
|
|
|
{
|
|
|
|
|
Name = _translationLookup["COMMANDS_ARGS_REASON"],
|
|
|
|
|
Required = true
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
2018-05-08 00:58:46 -04:00
|
|
|
|
|
2019-05-08 21:34:17 -04:00
|
|
|
|
public override async Task ExecuteAsync(GameEvent E)
|
2018-05-08 00:58:46 -04:00
|
|
|
|
{
|
2019-05-08 21:34:17 -04:00
|
|
|
|
switch ((await E.Target.Unflag(E.Data, E.Origin).WaitAsync(Utilities.DefaultCommandTimeout, E.Owner.Manager.CancellationToken)).FailReason)
|
2018-05-08 00:58:46 -04:00
|
|
|
|
{
|
2019-05-08 21:34:17 -04:00
|
|
|
|
case GameEvent.EventFailReason.None:
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Origin.Tell(_translationLookup["COMMANDS_FLAG_UNFLAG"].FormatExt(E.Target.Name));
|
2019-05-08 21:34:17 -04:00
|
|
|
|
break;
|
|
|
|
|
case GameEvent.EventFailReason.Permission:
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Origin.Tell(_translationLookup["COMMANDS_UNFLAG_FAIL"].FormatExt(E.Target.Name));
|
2019-05-08 21:34:17 -04:00
|
|
|
|
break;
|
|
|
|
|
case GameEvent.EventFailReason.Invalid:
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Origin.Tell(_translationLookup["COMMANDS_UNFLAG_NOTFLAGGED"]);
|
2019-05-08 21:34:17 -04:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Origin.Tell(_translationLookup["SERVER_ERROR_COMMAND_INGAME"]);
|
2019-05-08 21:34:17 -04:00
|
|
|
|
break;
|
2018-05-08 00:58:46 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-26 19:06:50 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Report client for given reason
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class ReportClientCommand : Command
|
2015-03-23 23:01:05 -04:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
public ReportClientCommand(CommandConfiguration config, ITranslationLookup translationLookup) : base(config, translationLookup)
|
|
|
|
|
{
|
|
|
|
|
Name = "report";
|
|
|
|
|
Description = _translationLookup["COMMANDS_REPORT_DESC"];
|
|
|
|
|
Alias = "rep";
|
|
|
|
|
Permission = Permission.User;
|
|
|
|
|
RequiresTarget = true;
|
|
|
|
|
Arguments = new[]
|
|
|
|
|
{
|
|
|
|
|
new CommandArgument()
|
2017-11-15 16:04:13 -05:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
Name = _translationLookup["COMMANDS_ARGS_PLAYER"],
|
|
|
|
|
Required = true
|
|
|
|
|
},
|
|
|
|
|
new CommandArgument()
|
|
|
|
|
{
|
|
|
|
|
Name = _translationLookup["COMMANDS_ARGS_REASON"],
|
|
|
|
|
Required = true
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
2015-03-23 23:01:05 -04:00
|
|
|
|
|
2018-09-29 15:52:22 -04:00
|
|
|
|
public override async Task ExecuteAsync(GameEvent commandEvent)
|
2015-03-23 23:01:05 -04:00
|
|
|
|
{
|
2018-09-29 15:52:22 -04:00
|
|
|
|
if (commandEvent.Data.ToLower().Contains("camp"))
|
2018-02-15 23:01:28 -05:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
commandEvent.Origin.Tell(_translationLookup["COMMANDS_REPORT_FAIL_CAMP"]);
|
2018-02-15 23:01:28 -05:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-08 21:34:17 -04:00
|
|
|
|
bool success = false;
|
2018-10-03 22:20:49 -04:00
|
|
|
|
|
2019-05-08 21:34:17 -04:00
|
|
|
|
switch ((await commandEvent.Target.Report(commandEvent.Data, commandEvent.Origin).WaitAsync(Utilities.DefaultCommandTimeout, commandEvent.Owner.Manager.CancellationToken)).FailReason)
|
2015-03-23 23:01:05 -04:00
|
|
|
|
{
|
2019-05-08 21:34:17 -04:00
|
|
|
|
case GameEvent.EventFailReason.None:
|
2020-01-26 19:06:50 -05:00
|
|
|
|
commandEvent.Origin.Tell(_translationLookup["COMMANDS_REPORT_SUCCESS"]);
|
2019-05-08 21:34:17 -04:00
|
|
|
|
success = true;
|
|
|
|
|
break;
|
|
|
|
|
case GameEvent.EventFailReason.Exception:
|
2020-01-26 19:06:50 -05:00
|
|
|
|
commandEvent.Origin.Tell(_translationLookup["COMMANDS_REPORT_FAIL_DUPLICATE"]);
|
2019-05-08 21:34:17 -04:00
|
|
|
|
break;
|
|
|
|
|
case GameEvent.EventFailReason.Permission:
|
2020-01-26 19:06:50 -05:00
|
|
|
|
commandEvent.Origin.Tell(_translationLookup["COMMANDS_REPORT_FAIL"].FormatExt(commandEvent.Target.Name));
|
2019-05-08 21:34:17 -04:00
|
|
|
|
break;
|
|
|
|
|
case GameEvent.EventFailReason.Invalid:
|
2020-01-26 19:06:50 -05:00
|
|
|
|
commandEvent.Origin.Tell(_translationLookup["COMMANDS_REPORT_FAIL_SELF"]);
|
2019-05-08 21:34:17 -04:00
|
|
|
|
break;
|
|
|
|
|
case GameEvent.EventFailReason.Throttle:
|
2020-01-26 19:06:50 -05:00
|
|
|
|
commandEvent.Origin.Tell(_translationLookup["COMMANDS_REPORT_FAIL_TOOMANY"]);
|
2019-05-08 21:34:17 -04:00
|
|
|
|
break;
|
2015-03-23 23:01:05 -04:00
|
|
|
|
}
|
|
|
|
|
|
2019-05-08 21:34:17 -04:00
|
|
|
|
if (success)
|
2018-05-24 15:48:57 -04:00
|
|
|
|
{
|
2018-09-29 15:52:22 -04:00
|
|
|
|
commandEvent.Owner.ToAdmins(String.Format("^5{0}^7->^1{1}^7: {2}", commandEvent.Origin.Name, commandEvent.Target.Name, commandEvent.Data));
|
|
|
|
|
}
|
2015-03-23 23:01:05 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-26 19:06:50 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// List all reports on the server
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class ListReportsCommand : Command
|
2015-03-23 23:01:05 -04:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
public ListReportsCommand(CommandConfiguration config, ITranslationLookup translationLookup) : base(config, translationLookup)
|
|
|
|
|
{
|
|
|
|
|
Name = "reports";
|
|
|
|
|
Description = _translationLookup["COMMANDS_REPORTS_DESC"];
|
|
|
|
|
Alias = "reps";
|
|
|
|
|
Permission = Permission.Moderator;
|
|
|
|
|
RequiresTarget = false;
|
|
|
|
|
Arguments = new[]
|
|
|
|
|
{
|
|
|
|
|
new CommandArgument()
|
2017-11-15 16:04:13 -05:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
Name = _translationLookup["COMMANDS_ARGS_CLEAR"],
|
|
|
|
|
Required = false
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
2015-03-23 23:01:05 -04:00
|
|
|
|
|
2018-09-29 15:52:22 -04:00
|
|
|
|
public override Task ExecuteAsync(GameEvent E)
|
2015-03-23 23:01:05 -04:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
if (E.Data != null && E.Data.ToLower().Contains(_translationLookup["COMMANDS_ARGS_CLEAR"]))
|
2015-08-26 01:49:47 -04:00
|
|
|
|
{
|
|
|
|
|
E.Owner.Reports = new List<Report>();
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Origin.Tell(_translationLookup["COMMANDS_REPORTS_CLEAR_SUCCESS"]);
|
2018-09-29 15:52:22 -04:00
|
|
|
|
return Task.CompletedTask;
|
2015-08-26 01:49:47 -04:00
|
|
|
|
}
|
|
|
|
|
|
2015-03-23 23:01:05 -04:00
|
|
|
|
if (E.Owner.Reports.Count < 1)
|
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Origin.Tell(_translationLookup["COMMANDS_REPORTS_NONE"]);
|
2018-09-29 15:52:22 -04:00
|
|
|
|
return Task.CompletedTask;
|
2015-03-23 23:01:05 -04:00
|
|
|
|
}
|
|
|
|
|
|
2017-05-26 18:49:27 -04:00
|
|
|
|
foreach (Report R in E.Owner.Reports)
|
2018-09-07 23:29:42 -04:00
|
|
|
|
{
|
2018-09-29 15:52:22 -04:00
|
|
|
|
E.Origin.Tell(String.Format("^5{0}^7->^1{1}^7: {2}", R.Origin.Name, R.Target.Name, R.Reason));
|
2018-09-07 23:29:42 -04:00
|
|
|
|
}
|
2018-09-29 15:52:22 -04:00
|
|
|
|
|
|
|
|
|
return Task.CompletedTask;
|
2015-03-23 23:01:05 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-26 19:06:50 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Masks client from announcements and online admin list
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class MaskCommand : Command
|
2015-04-10 00:02:12 -04:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
public MaskCommand(CommandConfiguration config, ITranslationLookup translationLookup) : base(config, translationLookup)
|
|
|
|
|
{
|
|
|
|
|
Name = "mask";
|
|
|
|
|
Description = _translationLookup["COMMANDS_MASK_DESC"];
|
|
|
|
|
Alias = "hide";
|
|
|
|
|
Permission = EFClient.Permission.Moderator;
|
|
|
|
|
RequiresTarget = false;
|
|
|
|
|
}
|
2015-04-10 00:02:12 -04:00
|
|
|
|
|
2018-04-13 02:32:30 -04:00
|
|
|
|
public override async Task ExecuteAsync(GameEvent E)
|
2015-04-10 00:02:12 -04:00
|
|
|
|
{
|
|
|
|
|
if (E.Origin.Masked)
|
|
|
|
|
{
|
|
|
|
|
E.Origin.Masked = false;
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Origin.Tell(_translationLookup["COMMANDS_MASK_OFF"]);
|
2015-04-10 00:02:12 -04:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
E.Origin.Masked = true;
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Origin.Tell(_translationLookup["COMMANDS_MASK_ON"]);
|
2015-04-10 00:02:12 -04:00
|
|
|
|
}
|
2017-06-19 13:58:01 -04:00
|
|
|
|
|
2017-11-25 20:29:58 -05:00
|
|
|
|
await E.Owner.Manager.GetClientService().Update(E.Origin);
|
2015-04-10 00:02:12 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-26 19:06:50 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Lists ban information for given client
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class ListBanInfoCommand : Command
|
2015-04-10 00:02:12 -04:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
public ListBanInfoCommand(CommandConfiguration config, ITranslationLookup translationLookup) : base(config, translationLookup)
|
|
|
|
|
{
|
|
|
|
|
Name = "baninfo";
|
|
|
|
|
Description = _translationLookup["COMMANDS_BANINFO_DESC"];
|
|
|
|
|
Alias = "bi";
|
|
|
|
|
Permission = Permission.Moderator;
|
|
|
|
|
RequiresTarget = true;
|
|
|
|
|
Arguments = new[]
|
|
|
|
|
{
|
|
|
|
|
new CommandArgument()
|
2017-11-15 16:04:13 -05:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
Name = _translationLookup["COMMANDS_ARGS_PLAYER"],
|
|
|
|
|
Required = true
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
2015-04-10 00:02:12 -04:00
|
|
|
|
|
2018-04-13 02:32:30 -04:00
|
|
|
|
public override async Task ExecuteAsync(GameEvent E)
|
2015-04-10 00:02:12 -04:00
|
|
|
|
{
|
2019-04-05 14:34:03 -04:00
|
|
|
|
var existingPenalties = await E.Owner.Manager.GetPenaltyService().GetActivePenaltiesAsync(E.Target.AliasLinkId, E.Target.IPAddress);
|
2019-05-29 17:55:35 -04:00
|
|
|
|
var penalty = existingPenalties.FirstOrDefault(b => b.Type > EFPenalty.PenaltyType.Kick);
|
2017-11-25 20:29:58 -05:00
|
|
|
|
|
|
|
|
|
if (penalty == null)
|
2015-04-10 00:02:12 -04:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Origin.Tell(_translationLookup["COMMANDS_BANINFO_NONE"]);
|
2015-04-10 00:02:12 -04:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-29 17:55:35 -04:00
|
|
|
|
if (penalty.Type == EFPenalty.PenaltyType.Ban)
|
2019-04-09 16:02:49 -04:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Origin.Tell(_translationLookup["COMMANDS_BANINFO_SUCCESS"].FormatExt(E.Target.Name, penalty.Offense));
|
2019-04-09 16:02:49 -04:00
|
|
|
|
}
|
2018-04-22 16:04:18 -04:00
|
|
|
|
|
2019-04-09 16:02:49 -04:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
string remainingTime = (penalty.Expires.Value - DateTime.UtcNow).TimeSpanText();
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Origin.Tell(_translationLookup["COMMANDS_BANINFO_TB_SUCCESS"].FormatExt(E.Target.Name, penalty.Offense, remainingTime));
|
2019-04-09 16:02:49 -04:00
|
|
|
|
}
|
2015-04-10 00:02:12 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-26 19:06:50 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Lists alises of specified client
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class ListAliasesCommand : Command
|
2015-04-10 00:02:12 -04:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
public ListAliasesCommand(CommandConfiguration config, ITranslationLookup translationLookup) : base(config, translationLookup)
|
|
|
|
|
{
|
|
|
|
|
Name = "alias";
|
|
|
|
|
Description = _translationLookup["COMMANDS_ALIAS_DESC"];
|
|
|
|
|
Alias = "known";
|
|
|
|
|
Permission = EFClient.Permission.Moderator;
|
|
|
|
|
RequiresTarget = true;
|
|
|
|
|
Arguments = new[]
|
|
|
|
|
{
|
|
|
|
|
new CommandArgument()
|
2017-11-15 16:04:13 -05:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
Name = _translationLookup["COMMANDS_ARGS_PLAYER"],
|
|
|
|
|
Required = true,
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
2015-04-10 00:02:12 -04:00
|
|
|
|
|
2018-09-29 15:52:22 -04:00
|
|
|
|
public override Task ExecuteAsync(GameEvent E)
|
2015-04-10 00:02:12 -04:00
|
|
|
|
{
|
|
|
|
|
StringBuilder message = new StringBuilder();
|
2017-11-25 20:29:58 -05:00
|
|
|
|
var names = new List<string>(E.Target.AliasLink.Children.Select(a => a.Name));
|
2018-02-10 23:33:42 -05:00
|
|
|
|
var IPs = new List<string>(E.Target.AliasLink.Children.Select(a => a.IPAddress.ConvertIPtoString()).Distinct());
|
2015-04-10 00:02:12 -04:00
|
|
|
|
|
2019-11-15 15:50:20 -05:00
|
|
|
|
E.Origin.Tell($"[^3{E.Target}^7]");
|
2017-08-17 19:28:08 -04:00
|
|
|
|
|
2020-01-26 19:06:50 -05:00
|
|
|
|
message.Append($"{_translationLookup["COMMANDS_ALIAS_ALIASES"]}: ");
|
2017-11-25 20:29:58 -05:00
|
|
|
|
message.Append(String.Join(" | ", names));
|
2018-09-29 15:52:22 -04:00
|
|
|
|
E.Origin.Tell(message.ToString());
|
2015-04-11 13:31:04 -04:00
|
|
|
|
|
2017-06-01 13:42:28 -04:00
|
|
|
|
message.Clear();
|
2020-01-26 19:06:50 -05:00
|
|
|
|
message.Append($"{_translationLookup["COMMANDS_ALIAS_IPS"]}: ");
|
2017-11-25 20:29:58 -05:00
|
|
|
|
message.Append(String.Join(" | ", IPs));
|
2018-09-29 15:52:22 -04:00
|
|
|
|
E.Origin.Tell(message.ToString());
|
|
|
|
|
|
|
|
|
|
return Task.CompletedTask;
|
2015-04-10 00:02:12 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-26 19:06:50 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Executes RCon command
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class ExecuteRConCommand : Command
|
2015-04-10 00:02:12 -04:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
public ExecuteRConCommand(CommandConfiguration config, ITranslationLookup translationLookup) : base(config, translationLookup)
|
|
|
|
|
{
|
|
|
|
|
Name = "rcon";
|
|
|
|
|
Description = _translationLookup["COMMANDS_RCON_DESC"];
|
|
|
|
|
Alias = "rcon";
|
|
|
|
|
Permission = Permission.Owner;
|
|
|
|
|
RequiresTarget = false;
|
|
|
|
|
Arguments = new[]
|
|
|
|
|
{
|
|
|
|
|
new CommandArgument()
|
2017-11-15 16:04:13 -05:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
Name = _translationLookup["COMMANDS_ARGS_COMMANDS"],
|
|
|
|
|
Required = true
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
2015-04-10 00:02:12 -04:00
|
|
|
|
|
2018-04-13 02:32:30 -04:00
|
|
|
|
public override async Task ExecuteAsync(GameEvent E)
|
2015-04-10 00:02:12 -04:00
|
|
|
|
{
|
2017-06-07 17:08:29 -04:00
|
|
|
|
var Response = await E.Owner.ExecuteCommandAsync(E.Data.Trim());
|
|
|
|
|
foreach (string S in Response)
|
2018-11-05 22:01:29 -05:00
|
|
|
|
{
|
2019-08-01 10:37:33 -04:00
|
|
|
|
E.Origin.Tell(S);
|
2018-11-05 22:01:29 -05:00
|
|
|
|
}
|
|
|
|
|
|
2017-06-07 17:08:29 -04:00
|
|
|
|
if (Response.Length == 0)
|
2018-11-05 22:01:29 -05:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Origin.Tell(_translationLookup["COMMANDS_RCON_SUCCESS"]);
|
2018-11-05 22:01:29 -05:00
|
|
|
|
}
|
2015-04-10 00:02:12 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-06-12 17:47:31 -04:00
|
|
|
|
|
2020-01-26 19:06:50 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Lists the loaded plugins
|
|
|
|
|
/// </summary>
|
2020-02-01 13:27:14 -05:00
|
|
|
|
/*public class ListPluginsCommand : Command
|
2017-06-12 17:47:31 -04:00
|
|
|
|
{
|
2020-01-31 21:15:07 -05:00
|
|
|
|
private readonly IPluginImporter _pluginImporter;
|
|
|
|
|
public ListPluginsCommand(CommandConfiguration config, ITranslationLookup translationLookup, IPluginImporter pluginImporter) : base(config, translationLookup)
|
2020-01-26 19:06:50 -05:00
|
|
|
|
{
|
|
|
|
|
Name = "plugins";
|
|
|
|
|
Description = _translationLookup["COMMANDS_PLUGINS_DESC"];
|
|
|
|
|
Alias = "p";
|
|
|
|
|
Permission = Permission.Administrator;
|
|
|
|
|
RequiresTarget = false;
|
2020-01-31 21:15:07 -05:00
|
|
|
|
_pluginImporter = pluginImporter;
|
2020-01-26 19:06:50 -05:00
|
|
|
|
}
|
2017-06-12 17:47:31 -04:00
|
|
|
|
|
2018-09-29 15:52:22 -04:00
|
|
|
|
public override Task ExecuteAsync(GameEvent E)
|
2017-06-12 17:47:31 -04:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Origin.Tell(_translationLookup["COMMANDS_PLUGINS_LOADED"]);
|
2020-01-31 21:15:07 -05:00
|
|
|
|
foreach (var P in _pluginImporter.ActivePlugins)
|
2017-06-12 17:47:31 -04:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Origin.Tell(string.Format("^3{0} ^7[v^3{1}^7] by ^5{2}^7", P.Name, P.Version, P.Author));
|
2017-06-12 17:47:31 -04:00
|
|
|
|
}
|
2018-09-29 15:52:22 -04:00
|
|
|
|
return Task.CompletedTask;
|
2017-06-12 17:47:31 -04:00
|
|
|
|
}
|
2020-02-01 13:27:14 -05:00
|
|
|
|
}*/
|
2017-08-17 19:28:08 -04:00
|
|
|
|
|
2020-01-26 19:06:50 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Lists external IP
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class ListExternalIPCommand : Command
|
2017-08-17 19:28:08 -04:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
public ListExternalIPCommand(CommandConfiguration config, ITranslationLookup translationLookup) : base(config, translationLookup)
|
|
|
|
|
{
|
|
|
|
|
Name = "getexternalip";
|
|
|
|
|
Description = _translationLookup["COMMANDS_IP_DESC"];
|
|
|
|
|
Alias = "ip";
|
|
|
|
|
Permission = Permission.User;
|
|
|
|
|
RequiresTarget = false;
|
|
|
|
|
}
|
2017-08-17 19:28:08 -04:00
|
|
|
|
|
2018-09-29 15:52:22 -04:00
|
|
|
|
public override Task ExecuteAsync(GameEvent E)
|
2017-08-17 19:28:08 -04:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Origin.Tell(_translationLookup["COMMANDS_IP_SUCCESS"].FormatExt(E.Origin.IPAddressString));
|
2018-09-29 15:52:22 -04:00
|
|
|
|
return Task.CompletedTask;
|
2017-08-17 19:28:08 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-02-10 01:26:38 -05:00
|
|
|
|
|
2020-01-26 19:06:50 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Prunes inactive privileged clients
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class PruneAdminsCommand : Command
|
2018-02-10 01:26:38 -05:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
public PruneAdminsCommand(CommandConfiguration config, ITranslationLookup translationLookup) : base(config, translationLookup)
|
2018-02-10 01:26:38 -05:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
Name = "prune";
|
|
|
|
|
Description = _translationLookup["COMMANDS_PRUNE_DESC"];
|
|
|
|
|
Alias = "pa";
|
|
|
|
|
Permission = Permission.Owner;
|
|
|
|
|
RequiresTarget = false;
|
|
|
|
|
Arguments = new[]
|
2018-02-10 01:26:38 -05:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
new CommandArgument()
|
|
|
|
|
{
|
|
|
|
|
Name = _translationLookup["COMMANDS_ARGS_INACTIVE"],
|
|
|
|
|
Required = false
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
2018-03-06 02:22:19 -05:00
|
|
|
|
|
2018-04-13 02:32:30 -04:00
|
|
|
|
public override async Task ExecuteAsync(GameEvent E)
|
2018-02-10 01:26:38 -05:00
|
|
|
|
{
|
|
|
|
|
int inactiveDays = 30;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (E.Data.Length > 0)
|
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
inactiveDays = int.Parse(E.Data);
|
2018-02-10 01:26:38 -05:00
|
|
|
|
if (inactiveDays < 1)
|
2018-11-05 22:01:29 -05:00
|
|
|
|
{
|
2018-02-10 01:26:38 -05:00
|
|
|
|
throw new FormatException();
|
2018-11-05 22:01:29 -05:00
|
|
|
|
}
|
2018-02-10 01:26:38 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
catch (FormatException)
|
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Origin.Tell(_translationLookup["COMMANDS_PRUNE_FAIL"]);
|
2018-02-10 01:26:38 -05:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<EFClient> inactiveUsers = null;
|
2018-09-29 15:52:22 -04:00
|
|
|
|
// todo: make an event for this
|
2018-02-10 01:26:38 -05:00
|
|
|
|
// update user roles
|
|
|
|
|
using (var context = new DatabaseContext())
|
|
|
|
|
{
|
|
|
|
|
var lastActive = DateTime.UtcNow.AddDays(-inactiveDays);
|
|
|
|
|
inactiveUsers = await context.Clients
|
2020-01-26 19:06:50 -05:00
|
|
|
|
.Where(c => c.Level > Permission.Flagged && c.Level <= Permission.Moderator)
|
2018-02-10 01:26:38 -05:00
|
|
|
|
.Where(c => c.LastConnection < lastActive)
|
|
|
|
|
.ToListAsync();
|
2019-06-11 09:00:14 -04:00
|
|
|
|
inactiveUsers.ForEach(c => c.SetLevel(Permission.User, E.Origin));
|
2018-02-10 01:26:38 -05:00
|
|
|
|
await context.SaveChangesAsync();
|
|
|
|
|
}
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Origin.Tell(_translationLookup["COMMANDS_PRUNE_SUCCESS"].FormatExt(inactiveUsers.Count));
|
2018-03-06 02:22:19 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-26 19:06:50 -05:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Sets login password
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class SetPasswordCommand : Command
|
2018-04-04 15:38:34 -04:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
public SetPasswordCommand(CommandConfiguration config, ITranslationLookup translationLookup) : base(config, translationLookup)
|
|
|
|
|
{
|
|
|
|
|
Name = "setpassword";
|
|
|
|
|
Description = _translationLookup["COMMANDS_SETPASSWORD_DESC"];
|
|
|
|
|
Alias = "sp";
|
|
|
|
|
Permission = Permission.Moderator;
|
|
|
|
|
RequiresTarget = false;
|
2020-04-26 22:12:49 -04:00
|
|
|
|
AllowImpersonation = true;
|
2020-01-26 19:06:50 -05:00
|
|
|
|
Arguments = new[]
|
2018-04-04 15:38:34 -04:00
|
|
|
|
{
|
|
|
|
|
new CommandArgument()
|
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
Name = _translationLookup["COMMANDS_ARGS_PASSWORD"],
|
2018-04-04 15:38:34 -04:00
|
|
|
|
Required = true
|
|
|
|
|
}
|
2020-01-26 19:06:50 -05:00
|
|
|
|
};
|
|
|
|
|
}
|
2018-04-04 15:38:34 -04:00
|
|
|
|
|
2018-04-13 02:32:30 -04:00
|
|
|
|
public override async Task ExecuteAsync(GameEvent E)
|
2018-04-04 15:38:34 -04:00
|
|
|
|
{
|
2018-04-05 00:38:45 -04:00
|
|
|
|
if (E.Data.Length < 5)
|
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Origin.Tell(_translationLookup["COMMANDS_PASSWORD_FAIL"]);
|
2018-04-05 00:38:45 -04:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-04 15:38:34 -04:00
|
|
|
|
string[] hashedPassword = Helpers.Hashing.Hash(E.Data);
|
|
|
|
|
|
|
|
|
|
E.Origin.Password = hashedPassword[0];
|
|
|
|
|
E.Origin.PasswordSalt = hashedPassword[1];
|
|
|
|
|
|
|
|
|
|
await E.Owner.Manager.GetClientService().Update(E.Origin);
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Origin.Tell(_translationLookup["COMMANDS_PASSWORD_SUCCESS"]);
|
2018-04-04 15:38:34 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-26 19:06:50 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the ping of a client
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class GetClientPingCommand : Command
|
2018-03-06 02:22:19 -05:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
public GetClientPingCommand(CommandConfiguration config, ITranslationLookup translationLookup) : base(config, translationLookup)
|
2018-03-06 02:22:19 -05:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
Name = "ping";
|
|
|
|
|
Description = _translationLookup["COMMANDS_PING_DESC"];
|
|
|
|
|
Alias = "pi";
|
|
|
|
|
Permission = Permission.User;
|
|
|
|
|
RequiresTarget = false;
|
|
|
|
|
Arguments = new[]
|
2018-05-05 16:36:26 -04:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
new CommandArgument()
|
2018-03-06 02:22:19 -05:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
Name = _translationLookup["COMMANDS_ARGS_PLAYER"],
|
|
|
|
|
Required = false
|
2018-03-06 02:22:19 -05:00
|
|
|
|
}
|
2020-01-26 19:06:50 -05:00
|
|
|
|
};
|
2018-02-10 01:26:38 -05:00
|
|
|
|
}
|
2018-04-14 00:51:38 -04:00
|
|
|
|
|
2018-09-29 15:52:22 -04:00
|
|
|
|
public override Task ExecuteAsync(GameEvent E)
|
2018-04-14 00:51:38 -04:00
|
|
|
|
{
|
2019-04-08 21:31:32 -04:00
|
|
|
|
if (E.Target == null)
|
|
|
|
|
{
|
|
|
|
|
E.Target = E.Owner.GetClientByName(E.Data).FirstOrDefault();
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-09 16:02:49 -04:00
|
|
|
|
if (E.Target == null)
|
2018-04-14 00:51:38 -04:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Origin.Tell(_translationLookup["COMMANDS_PING_SELF"].FormatExt(E.Origin.Ping));
|
2018-04-14 00:51:38 -04:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Origin.Tell(_translationLookup["COMMANDS_PING_TARGET"].FormatExt(E.Target.Name, E.Target.Ping));
|
2018-04-14 00:51:38 -04:00
|
|
|
|
}
|
2018-09-29 15:52:22 -04:00
|
|
|
|
|
|
|
|
|
return Task.CompletedTask;
|
2018-04-14 00:51:38 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-06-02 00:48:10 -04:00
|
|
|
|
|
2020-01-26 19:06:50 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Sets the email for gravatar in webfront
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class SetGravatarCommand : Command
|
2018-06-02 00:48:10 -04:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
public SetGravatarCommand(CommandConfiguration config, ITranslationLookup translationLookup) : base(config, translationLookup)
|
2018-06-02 00:48:10 -04:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
Name = "setgravatar";
|
|
|
|
|
Description = _translationLookup["COMMANDS_GRAVATAR_DESC"];
|
|
|
|
|
Alias = "sg";
|
|
|
|
|
Permission = Permission.User;
|
|
|
|
|
RequiresTarget = false;
|
|
|
|
|
Arguments = new[]
|
2018-06-02 00:48:10 -04:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
new CommandArgument()
|
|
|
|
|
{
|
|
|
|
|
Name = _translationLookup["COMMANDS_ARGS_GRAVATAR"],
|
|
|
|
|
Required = true
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
2018-06-02 00:48:10 -04:00
|
|
|
|
|
|
|
|
|
public override async Task ExecuteAsync(GameEvent E)
|
|
|
|
|
{
|
2019-04-09 16:02:49 -04:00
|
|
|
|
var metaSvc = new MetaService();
|
2018-06-02 00:48:10 -04:00
|
|
|
|
|
2019-04-09 16:02:49 -04:00
|
|
|
|
using (var md5 = MD5.Create())
|
|
|
|
|
{
|
|
|
|
|
string gravatarEmail = string.Concat(md5.ComputeHash(E.Data.ToLower().Select(d => Convert.ToByte(d)).ToArray())
|
2018-06-02 00:48:10 -04:00
|
|
|
|
.Select(h => h.ToString("x2")));
|
2019-04-09 16:02:49 -04:00
|
|
|
|
await metaSvc.AddPersistentMeta("GravatarEmail", gravatarEmail, E.Origin);
|
2018-06-02 00:48:10 -04:00
|
|
|
|
}
|
2019-04-09 16:02:49 -04:00
|
|
|
|
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Origin.Tell(_translationLookup["COMMANDS_GRAVATAR_SUCCESS_NEW"]);
|
2018-06-02 00:48:10 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-06-02 22:21:01 -04:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Retrieves the next map in rotation
|
|
|
|
|
/// </summary>
|
2020-01-26 19:06:50 -05:00
|
|
|
|
public class NextMapCommand : Command
|
2018-06-02 22:21:01 -04:00
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
public NextMapCommand(CommandConfiguration config, ITranslationLookup translationLookup) : base(config, translationLookup)
|
|
|
|
|
{
|
|
|
|
|
Name = "nextmap";
|
|
|
|
|
Description = _translationLookup["COMMANDS_NEXTMAP_DESC"];
|
|
|
|
|
Alias = "nm";
|
|
|
|
|
Permission = EFClient.Permission.User;
|
|
|
|
|
RequiresTarget = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static async Task<string> GetNextMap(Server s, ITranslationLookup lookup)
|
2018-06-02 22:21:01 -04:00
|
|
|
|
{
|
2019-04-16 12:32:42 -04:00
|
|
|
|
string mapRotation = (await s.GetDvarAsync<string>("sv_mapRotation")).Value?.ToLower() ?? "";
|
|
|
|
|
var regexMatches = Regex.Matches(mapRotation, @"((?:gametype|exec) +(?:([a-z]{1,4})(?:.cfg)?))? *map ([a-z|_|\d]+)", RegexOptions.IgnoreCase).ToList();
|
2018-06-05 17:31:36 -04:00
|
|
|
|
|
2018-06-02 22:21:01 -04:00
|
|
|
|
// find the current map in the rotation
|
|
|
|
|
var currentMap = regexMatches.Where(m => m.Groups[3].ToString() == s.CurrentMap.Name);
|
|
|
|
|
var lastMap = regexMatches.LastOrDefault();
|
|
|
|
|
Map nextMap = null;
|
|
|
|
|
|
2018-06-05 17:31:36 -04:00
|
|
|
|
// no maprotation at all
|
|
|
|
|
if (regexMatches.Count() == 0)
|
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
return lookup["COMMANDS_NEXTMAP_SUCCESS"].FormatExt(s.CurrentMap.Alias, Utilities.GetLocalizedGametype(s.Gametype));
|
2018-06-05 17:31:36 -04:00
|
|
|
|
}
|
|
|
|
|
|
2018-06-02 22:21:01 -04:00
|
|
|
|
// the current map is not in rotation
|
|
|
|
|
if (currentMap.Count() == 0)
|
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
return lookup["COMMANDS_NEXTMAP_NOT_IN_ROTATION"];
|
2018-06-02 22:21:01 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// there's duplicate maps in rotation
|
|
|
|
|
else if (currentMap.Count() > 1)
|
|
|
|
|
{
|
|
|
|
|
// gametype has been manually specified
|
|
|
|
|
var duplicateMaps = currentMap.Where(m => !string.IsNullOrEmpty(m.Groups[1].ToString()));
|
|
|
|
|
|
|
|
|
|
// more than one instance of map in rotation
|
|
|
|
|
if (duplicateMaps.Count() > 0)
|
|
|
|
|
{
|
|
|
|
|
currentMap = duplicateMaps.Where(m => m.Groups[2].ToString() == s.Gametype);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// else we just have to assume it's the first one
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// if the current map is the last map, the next map is the first map
|
|
|
|
|
var nextMapMatch = currentMap.First().Index != lastMap.Index ?
|
|
|
|
|
regexMatches[regexMatches.IndexOf(currentMap.First()) + 1] :
|
|
|
|
|
regexMatches.First();
|
2018-10-03 22:20:49 -04:00
|
|
|
|
|
2019-04-16 12:32:42 -04:00
|
|
|
|
string nextMapName = nextMapMatch.Groups[3].ToString();
|
|
|
|
|
|
|
|
|
|
nextMap = s.Maps.FirstOrDefault(m => m.Name == nextMapMatch.Groups[3].ToString()) ?? new Map() { Alias = nextMapName, Name = nextMapName };
|
2018-06-02 22:21:01 -04:00
|
|
|
|
string nextGametype = nextMapMatch.Groups[2].ToString().Length == 0 ?
|
|
|
|
|
Utilities.GetLocalizedGametype(s.Gametype) :
|
|
|
|
|
Utilities.GetLocalizedGametype(nextMapMatch.Groups[2].ToString());
|
|
|
|
|
|
2020-01-26 19:06:50 -05:00
|
|
|
|
return lookup["COMMANDS_NEXTMAP_SUCCESS"].FormatExt(nextMap.Alias, nextGametype);
|
2018-06-02 22:21:01 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override async Task ExecuteAsync(GameEvent E)
|
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
E.Origin.Tell(await GetNextMap(E.Owner, _translationLookup));
|
2018-06-02 22:21:01 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-09-29 15:52:22 -04:00
|
|
|
|
}
|