2018-04-08 02:44:42 -04:00
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
using SharedLibraryCore.Database;
|
|
|
|
|
using SharedLibraryCore.Database.Models;
|
|
|
|
|
using SharedLibraryCore.Objects;
|
|
|
|
|
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.Net;
|
|
|
|
|
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;
|
|
|
|
|
|
2018-04-08 02:44:42 -04:00
|
|
|
|
namespace SharedLibraryCore.Commands
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2017-06-19 13:58:01 -04:00
|
|
|
|
public class CQuit : Command
|
2017-05-26 18:49:27 -04:00
|
|
|
|
{
|
2017-11-15 16:04:13 -05:00
|
|
|
|
public CQuit() :
|
2019-03-24 22:34:20 -04:00
|
|
|
|
base("quit", Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_QUIT_DESC"], "q", EFClient.Permission.Owner, false)
|
2017-11-15 16:04:13 -05:00
|
|
|
|
{ }
|
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
|
|
|
|
{
|
2017-06-12 13:50:00 -04:00
|
|
|
|
return Task.Run(() => { E.Owner.Manager.Stop(); });
|
2017-05-26 18:49:27 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-19 13:58:01 -04:00
|
|
|
|
public class COwner : Command
|
2017-08-17 19:28:08 -04:00
|
|
|
|
{
|
2017-11-15 16:04:13 -05:00
|
|
|
|
public COwner() :
|
2019-03-24 22:34:20 -04:00
|
|
|
|
base("owner", Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_OWNER_DESC"], "iamgod", EFClient.Permission.User, false)
|
2017-11-15 16:04:13 -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-03-24 22:34:20 -04:00
|
|
|
|
if (await (E.Owner.Manager.GetClientService() as ClientService).GetOwnerCount() == 0 &&
|
|
|
|
|
!E.Target.SetLevel(EFClient.Permission.Owner, Utilities.IW4MAdminClient(E.Owner)).Failed)
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2018-09-29 15:52:22 -04:00
|
|
|
|
E.Origin.Tell(Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_OWNER_SUCCESS"]);
|
2015-03-08 17:20:10 -04:00
|
|
|
|
}
|
|
|
|
|
else
|
2018-09-29 15:52:22 -04:00
|
|
|
|
{
|
|
|
|
|
E.Origin.Tell(Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_OWNER_FAIL"]);
|
|
|
|
|
}
|
2015-03-08 17:20:10 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-19 16:46:31 -04:00
|
|
|
|
public class CWarn : Command
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2017-11-15 16:04:13 -05:00
|
|
|
|
public CWarn() :
|
2019-03-24 22:34:20 -04:00
|
|
|
|
base("warn", Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_WARN_DESC"], "w", EFClient.Permission.Trusted, true, new CommandArgument[]
|
2017-11-15 16:04:13 -05:00
|
|
|
|
{
|
|
|
|
|
new CommandArgument()
|
|
|
|
|
{
|
2018-05-05 16:36:26 -04:00
|
|
|
|
Name = Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_ARGS_PLAYER"],
|
2017-11-15 16:04:13 -05:00
|
|
|
|
Required = true
|
|
|
|
|
},
|
|
|
|
|
new CommandArgument()
|
|
|
|
|
{
|
2018-05-05 16:36:26 -04:00
|
|
|
|
Name = Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_ARGS_REASON"],
|
2017-11-15 16:04:13 -05:00
|
|
|
|
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
|
|
|
|
{
|
2018-09-29 15:52:22 -04:00
|
|
|
|
E.Origin.Tell($"{Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_WARN_FAIL"]} {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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-19 13:58:01 -04:00
|
|
|
|
public class CWarnClear : Command
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2017-11-15 16:04:13 -05:00
|
|
|
|
public CWarnClear() :
|
2019-03-24 22:34:20 -04:00
|
|
|
|
base("warnclear", Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_WARNCLEAR_DESC"], "wc", EFClient.Permission.Trusted, true, new CommandArgument[]
|
2017-11-15 16:04:13 -05:00
|
|
|
|
{
|
|
|
|
|
new CommandArgument()
|
|
|
|
|
{
|
2018-05-05 16:36:26 -04:00
|
|
|
|
Name = Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_ARGS_PLAYER"],
|
2017-11-15 16:04:13 -05:00
|
|
|
|
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
|
|
|
|
{
|
|
|
|
|
E.Owner.Broadcast($"{Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_WARNCLEAR_SUCCESS"]} {E.Target.Name}");
|
|
|
|
|
}
|
2018-09-29 22:49:12 -04:00
|
|
|
|
|
|
|
|
|
return Task.CompletedTask;
|
2015-03-08 17:20:10 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-19 13:58:01 -04:00
|
|
|
|
public class CKick : Command
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2017-11-15 16:04:13 -05:00
|
|
|
|
public CKick() :
|
2019-03-24 22:34:20 -04:00
|
|
|
|
base("kick", Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_KICK_DESC"], "k", EFClient.Permission.Moderator, true, new CommandArgument[]
|
2017-11-15 16:04:13 -05:00
|
|
|
|
{
|
|
|
|
|
new CommandArgument()
|
|
|
|
|
{
|
2018-05-05 16:36:26 -04:00
|
|
|
|
Name = Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_ARGS_PLAYER"],
|
2017-11-15 16:04:13 -05:00
|
|
|
|
Required = true
|
|
|
|
|
},
|
|
|
|
|
new CommandArgument()
|
|
|
|
|
{
|
2018-05-05 16:36:26 -04:00
|
|
|
|
Name = Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_ARGS_REASON"],
|
2018-04-24 18:01:27 -04:00
|
|
|
|
Required = true
|
2017-11-15 16:04:13 -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-10-02 13:39:08 -04:00
|
|
|
|
var _ = !(await E.Target.Kick(E.Data, E.Origin).WaitAsync()).Failed ?
|
2018-09-29 15:52:22 -04:00
|
|
|
|
E.Origin.Tell($"^5{E.Target} ^7{Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_KICK_SUCCESS"]}") :
|
|
|
|
|
E.Origin.Tell($"{Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_KICK_FAIL"]} {E.Target.Name}");
|
2015-03-08 17:20:10 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-19 13:58:01 -04:00
|
|
|
|
public class CSay : Command
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2017-11-15 16:04:13 -05:00
|
|
|
|
public CSay() :
|
2019-03-24 22:34:20 -04:00
|
|
|
|
base("say", Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_SAY_DESC"], "s", EFClient.Permission.Moderator, false, new CommandArgument[]
|
2017-11-15 16:04:13 -05:00
|
|
|
|
{
|
|
|
|
|
new CommandArgument()
|
|
|
|
|
{
|
2018-05-05 16:36:26 -04:00
|
|
|
|
Name = Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_ARGS_MESSAGE"],
|
2017-11-15 16:04:13 -05:00
|
|
|
|
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);
|
|
|
|
|
return Task.CompletedTask;
|
2015-03-08 17:20:10 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-19 13:58:01 -04:00
|
|
|
|
public class CTempBan : Command
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2017-11-15 16:04:13 -05:00
|
|
|
|
public CTempBan() :
|
2019-03-24 22:34:20 -04:00
|
|
|
|
base("tempban", Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_TEMPBAN_DESC"], "tb", EFClient.Permission.Administrator, true, new CommandArgument[]
|
2017-11-15 16:04:13 -05:00
|
|
|
|
{
|
|
|
|
|
new CommandArgument()
|
|
|
|
|
{
|
2018-05-05 16:36:26 -04:00
|
|
|
|
Name = Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_ARGS_PLAYER"],
|
2017-11-15 16:04:13 -05:00
|
|
|
|
Required = true
|
|
|
|
|
},
|
|
|
|
|
new CommandArgument()
|
|
|
|
|
{
|
2018-05-05 16:36:26 -04:00
|
|
|
|
Name = Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_ARGS_DURATION"],
|
2017-11-15 16:04:13 -05:00
|
|
|
|
Required = true,
|
|
|
|
|
},
|
|
|
|
|
new CommandArgument()
|
|
|
|
|
{
|
2018-05-05 16:36:26 -04:00
|
|
|
|
Name = Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_ARGS_REASON"],
|
2017-11-15 16:04:13 -05:00
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
E.Origin.Tell(Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_TEMPBAN_FAIL_TOOLONG"]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var _ = !(await E.Target.TempBan(tempbanReason, length, E.Origin).WaitAsync()).Failed ?
|
|
|
|
|
E.Origin.Tell($"^5{E.Target} ^7{Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_TEMPBAN_SUCCESS"]} ^5{length.TimeSpanText()}") :
|
|
|
|
|
E.Origin.Tell($"{Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_TEMPBAN_FAIL"]} {E.Target.Name}");
|
|
|
|
|
}
|
2018-10-02 13:39:08 -04:00
|
|
|
|
}
|
2015-03-08 17:20:10 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-19 13:58:01 -04:00
|
|
|
|
public class CBan : Command
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2017-11-15 16:04:13 -05:00
|
|
|
|
public CBan() :
|
2019-03-24 22:34:20 -04:00
|
|
|
|
base("ban", Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_BAN_DESC"], "b", EFClient.Permission.SeniorAdmin, true, new CommandArgument[]
|
2017-11-15 16:04:13 -05:00
|
|
|
|
{
|
|
|
|
|
new CommandArgument()
|
|
|
|
|
{
|
2018-05-05 16:36:26 -04:00
|
|
|
|
Name = Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_ARGS_PLAYER"],
|
2017-11-15 16:04:13 -05:00
|
|
|
|
Required = true
|
|
|
|
|
},
|
|
|
|
|
new CommandArgument()
|
|
|
|
|
{
|
2018-05-05 16:36:26 -04:00
|
|
|
|
Name = Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_ARGS_REASON"],
|
2017-11-16 18:09:19 -05:00
|
|
|
|
Required = true
|
2017-11-15 16:04:13 -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-12-17 14:45:16 -05:00
|
|
|
|
var _ = !(await E.Target.Ban(E.Data, E.Origin, false).WaitAsync()).Failed ?
|
2018-09-29 15:52:22 -04:00
|
|
|
|
E.Origin.Tell($"^5{E.Target} ^7{Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_BAN_SUCCESS"]}") :
|
|
|
|
|
E.Origin.Tell($"{Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_BAN_FAIL"]} {E.Target.Name}");
|
2015-03-08 17:20:10 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-19 13:58:01 -04:00
|
|
|
|
public class CUnban : Command
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2017-11-15 16:04:13 -05:00
|
|
|
|
public CUnban() :
|
2019-03-24 22:34:20 -04:00
|
|
|
|
base("unban", Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_UNBAN_DESC"], "ub", EFClient.Permission.SeniorAdmin, true, new CommandArgument[]
|
2017-11-15 16:04:13 -05:00
|
|
|
|
{
|
|
|
|
|
new CommandArgument()
|
|
|
|
|
{
|
2018-05-05 16:36:26 -04:00
|
|
|
|
Name = Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_ARGS_CLIENTID"],
|
2017-11-15 16:04:13 -05:00
|
|
|
|
Required = true,
|
2018-02-17 01:13:38 -05:00
|
|
|
|
},
|
|
|
|
|
new CommandArgument()
|
|
|
|
|
{
|
2018-05-05 16:36:26 -04:00
|
|
|
|
Name = Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_ARGS_REASON"],
|
2018-02-17 01:13:38 -05:00
|
|
|
|
Required = true
|
2017-11-15 16:04:13 -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-02-17 01:13:38 -05:00
|
|
|
|
var penalties = await E.Owner.Manager.GetPenaltyService().GetActivePenaltiesAsync(E.Target.AliasLinkId);
|
2018-04-13 02:32:30 -04:00
|
|
|
|
if (penalties.Where(p => p.Type == Penalty.PenaltyType.Ban || p.Type == Penalty.PenaltyType.TempBan).FirstOrDefault() != null)
|
2018-02-17 01:13:38 -05:00
|
|
|
|
{
|
2018-09-29 15:52:22 -04:00
|
|
|
|
await E.Target.Unban(E.Data, E.Origin).WaitAsync();
|
|
|
|
|
E.Origin.Tell($"{Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_UNBAN_SUCCESS"]} {E.Target}");
|
2018-02-17 01:13:38 -05:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2018-09-29 15:52:22 -04:00
|
|
|
|
E.Origin.Tell($"{E.Target} {Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_UNBAN_FAIL"]}");
|
2018-02-17 01:13:38 -05:00
|
|
|
|
}
|
2015-03-08 17:20:10 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-19 13:58:01 -04:00
|
|
|
|
public class CWhoAmI : Command
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2017-11-15 16:04:13 -05:00
|
|
|
|
public CWhoAmI() :
|
2019-03-24 22:34:20 -04:00
|
|
|
|
base("whoami", Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_WHO_DESC"], "who", EFClient.Permission.User, false)
|
2017-11-15 16:04:13 -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
|
|
|
|
{
|
2018-10-25 09:14:39 -04: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);
|
2018-09-29 15:52:22 -04:00
|
|
|
|
E.Origin.Tell(You);
|
|
|
|
|
|
|
|
|
|
return Task.CompletedTask;
|
2015-03-08 17:20:10 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-19 13:58:01 -04:00
|
|
|
|
public class CList : Command
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2017-11-15 16:04:13 -05:00
|
|
|
|
public CList() :
|
2019-03-24 22:34:20 -04:00
|
|
|
|
base("list", Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_LIST_DESC"], "l", EFClient.Permission.Moderator, false)
|
2017-11-15 16:04:13 -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
|
|
|
|
{
|
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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-19 13:58:01 -04:00
|
|
|
|
public class CHelp : Command
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2017-11-15 16:04:13 -05:00
|
|
|
|
public CHelp() :
|
2019-03-24 22:34:20 -04:00
|
|
|
|
base("help", Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_HELP_DESC"], "h", EFClient.Permission.User, false, new CommandArgument[]
|
2017-11-15 16:04:13 -05:00
|
|
|
|
{
|
|
|
|
|
new CommandArgument()
|
|
|
|
|
{
|
2018-05-05 16:36:26 -04:00
|
|
|
|
Name = Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_ARGS_COMMANDS"],
|
2017-11-15 16:04:13 -05:00
|
|
|
|
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
|
|
|
|
{
|
|
|
|
|
String cmd = E.Data.Trim();
|
|
|
|
|
|
|
|
|
|
if (cmd.Length > 2)
|
|
|
|
|
{
|
|
|
|
|
bool found = false;
|
2017-05-26 18:49:27 -04:00
|
|
|
|
foreach (Command C in E.Owner.Manager.GetCommands())
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2018-04-19 01:48:14 -04:00
|
|
|
|
if (C.Name == cmd.ToLower() ||
|
|
|
|
|
C.Alias == cmd.ToLower())
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2018-09-29 15:52:22 -04:00
|
|
|
|
E.Origin.Tell($"[^3{C.Name}^7] {C.Description}");
|
|
|
|
|
E.Origin.Tell(C.Syntax);
|
2015-03-08 17:20:10 -04:00
|
|
|
|
found = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!found)
|
2018-09-29 15:52:22 -04:00
|
|
|
|
{
|
|
|
|
|
E.Origin.Tell(Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_HELP_NOTFOUND"]);
|
|
|
|
|
}
|
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());
|
|
|
|
|
E.Origin.Tell(Utilities.CurrentLocalization.LocalizationIndex["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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-19 13:58:01 -04:00
|
|
|
|
public class CFastRestart : Command
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2017-11-15 16:04:13 -05:00
|
|
|
|
public CFastRestart() :
|
2019-03-24 22:34:20 -04:00
|
|
|
|
base("fastrestart", Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_FASTRESTART_DESC"], "fr", EFClient.Permission.Moderator, false)
|
2017-11-15 16:04:13 -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-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 ?
|
|
|
|
|
E.Owner.Broadcast($"^5{E.Origin.Name} ^7{Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_FASTRESTART_UNMASKED"]}") :
|
|
|
|
|
E.Owner.Broadcast(Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_FASTRESTART_MASKED"]);
|
2015-03-08 17:20:10 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-19 13:58:01 -04:00
|
|
|
|
public class CMapRotate : Command
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2017-11-15 16:04:13 -05:00
|
|
|
|
public CMapRotate() :
|
2019-03-24 22:34:20 -04:00
|
|
|
|
base("maprotate", Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_MAPROTATE_DESC"], "mr", EFClient.Permission.Administrator, false)
|
2017-11-15 16:04:13 -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-09-29 15:52:22 -04:00
|
|
|
|
var _ = !E.Origin.Masked ?
|
|
|
|
|
E.Owner.Broadcast($"{Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_MAPROTATE"]} [^5{E.Origin.Name}^7]", E.Origin) :
|
|
|
|
|
E.Owner.Broadcast(Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_MAPROTATE"], E.Origin);
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-19 13:58:01 -04:00
|
|
|
|
public class CSetLevel : Command
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2017-11-15 16:04:13 -05:00
|
|
|
|
public CSetLevel() :
|
2019-03-24 22:34:20 -04:00
|
|
|
|
base("setlevel", Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_SETLEVEL_DESC"], "sl", EFClient.Permission.Moderator, true, new CommandArgument[]
|
2017-11-15 16:04:13 -05:00
|
|
|
|
{
|
|
|
|
|
new CommandArgument()
|
|
|
|
|
{
|
2018-05-05 16:36:26 -04:00
|
|
|
|
Name = Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_ARGS_PLAYER"],
|
2017-11-15 16:04:13 -05:00
|
|
|
|
Required = true
|
|
|
|
|
},
|
|
|
|
|
new CommandArgument()
|
|
|
|
|
{
|
2018-05-05 16:36:26 -04:00
|
|
|
|
Name = Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_ARGS_LEVEL"],
|
2017-11-15 16:04:13 -05:00
|
|
|
|
Required = true
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
{ }
|
2015-03-08 17:20:10 -04:00
|
|
|
|
|
2019-03-24 22:34:20 -04:00
|
|
|
|
public override Task ExecuteAsync(GameEvent E)
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2019-03-24 22:34:20 -04:00
|
|
|
|
|
|
|
|
|
EFClient.Permission oldPerm = E.Target.Level;
|
|
|
|
|
EFClient.Permission newPerm = Utilities.MatchPermission(E.Data);
|
|
|
|
|
|
2015-03-08 17:20:10 -04:00
|
|
|
|
if (E.Target == E.Origin)
|
|
|
|
|
{
|
2018-09-29 15:52:22 -04:00
|
|
|
|
E.Origin.Tell(Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_SETLEVEL_SELF"]);
|
2019-03-24 22:34:20 -04:00
|
|
|
|
return Task.CompletedTask;
|
2015-03-08 17:20:10 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2019-03-24 22:34:20 -04:00
|
|
|
|
else if (newPerm == EFClient.Permission.Owner &&
|
2018-03-24 17:35:54 -04:00
|
|
|
|
!E.Owner.Manager.GetApplicationSettings().Configuration().EnableMultipleOwners)
|
2017-06-19 13:58:01 -04:00
|
|
|
|
{
|
2019-03-24 22:34:20 -04:00
|
|
|
|
// only one owner is allowed
|
2018-09-29 15:52:22 -04:00
|
|
|
|
E.Origin.Tell(Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_SETLEVEL_OWNER"]);
|
2019-03-24 22:34:20 -04:00
|
|
|
|
return Task.CompletedTask;
|
2017-06-19 13:58:01 -04:00
|
|
|
|
}
|
|
|
|
|
|
2019-03-24 22:34:20 -04:00
|
|
|
|
else if (E.Origin.Level < EFClient.Permission.Owner &&
|
2018-03-24 17:35:54 -04:00
|
|
|
|
!E.Owner.Manager.GetApplicationSettings().Configuration().EnableSteppedHierarchy)
|
|
|
|
|
{
|
2019-03-24 22:34:20 -04:00
|
|
|
|
// only the owner is allowed to set levels
|
2018-09-29 15:52:22 -04:00
|
|
|
|
E.Origin.Tell($"{Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_SETLEVEL_STEPPEDDISABLED"]} ^5{E.Target.Name}");
|
2019-03-24 22:34:20 -04:00
|
|
|
|
return Task.CompletedTask;
|
2018-03-24 17:35:54 -04:00
|
|
|
|
}
|
|
|
|
|
|
2019-03-24 22:34:20 -04:00
|
|
|
|
else if (E.Origin.Level <= newPerm &&
|
|
|
|
|
E.Origin.Level < EFClient.Permission.Owner)
|
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
|
|
|
|
|
E.Origin.Tell(string.Format(Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_SETLEVEL_LEVELTOOHIGH"], E.Target.Name, (E.Origin.Level - 1).ToString()));
|
|
|
|
|
return Task.CompletedTask;
|
2018-03-24 17:35:54 -04:00
|
|
|
|
}
|
|
|
|
|
|
2019-03-24 22:34:20 -04:00
|
|
|
|
else if (newPerm > EFClient.Permission.Banned)
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2018-03-06 02:22:19 -05:00
|
|
|
|
var ActiveClient = E.Owner.Manager.GetActiveClients()
|
|
|
|
|
.FirstOrDefault(p => p.NetworkId == E.Target.NetworkId);
|
2017-06-12 13:50:00 -04:00
|
|
|
|
|
2017-06-19 13:58:01 -04:00
|
|
|
|
if (ActiveClient != null)
|
2018-02-24 00:56:03 -05:00
|
|
|
|
{
|
2019-03-24 22:34:20 -04:00
|
|
|
|
ActiveClient.SetLevel(newPerm, E.Origin);
|
2018-10-15 20:51:04 -04:00
|
|
|
|
|
2019-03-24 22:34:20 -04:00
|
|
|
|
// inform the client that they were promoted
|
|
|
|
|
// we don't really want to tell them if they're demoted haha
|
2018-10-15 20:51:04 -04:00
|
|
|
|
if (newPerm > oldPerm)
|
|
|
|
|
{
|
|
|
|
|
ActiveClient.Tell($"{Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_SETLEVEL_SUCCESS_TARGET"]} {newPerm}");
|
|
|
|
|
}
|
2018-02-24 00:56:03 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
{
|
2019-03-24 22:34:20 -04:00
|
|
|
|
E.Target.SetLevel(newPerm, E.Origin);
|
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 ?
|
2018-10-15 20:51:04 -04:00
|
|
|
|
E.Origin.Tell($"{Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_SETLEVEL_DEMOTE_SUCCESS"]} {E.Target.Name}") :
|
|
|
|
|
E.Origin.Tell($"{E.Target.Name} {Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_SETLEVEL_SUCCESS"]}");
|
2015-03-08 17:20:10 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else
|
2018-09-29 15:52:22 -04:00
|
|
|
|
{
|
|
|
|
|
E.Origin.Tell(Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_SETLEVEL_FAIL"]);
|
|
|
|
|
}
|
2019-03-24 22:34:20 -04:00
|
|
|
|
|
|
|
|
|
return Task.CompletedTask;
|
2015-03-08 17:20:10 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-19 13:58:01 -04:00
|
|
|
|
public class CUsage : Command
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2017-11-15 16:04:13 -05:00
|
|
|
|
public CUsage() :
|
2019-03-24 22:34:20 -04:00
|
|
|
|
base("usage", Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_USAGE_DESC"], "us", EFClient.Permission.Moderator, false)
|
2017-11-15 16:04:13 -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
|
|
|
|
{
|
2018-09-29 15:52:22 -04:00
|
|
|
|
E.Origin.Tell($"IW4MAdmin {Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_USAGE_TEXT"]} " + Math.Round(((System.Diagnostics.Process.GetCurrentProcess().PrivateMemorySize64 / 2048f) / 1200f), 1) + "MB");
|
|
|
|
|
return Task.CompletedTask;
|
2015-03-08 17:20:10 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-19 13:58:01 -04:00
|
|
|
|
public class CUptime : Command
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2017-11-15 16:04:13 -05:00
|
|
|
|
public CUptime() :
|
2019-03-24 22:34:20 -04:00
|
|
|
|
base("uptime", Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_UPTIME_DESC"], "up", EFClient.Permission.Moderator, false)
|
2017-11-15 16:04:13 -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
|
|
|
|
{
|
|
|
|
|
TimeSpan uptime = DateTime.Now - System.Diagnostics.Process.GetCurrentProcess().StartTime;
|
2018-05-05 16:36:26 -04:00
|
|
|
|
var loc = Utilities.CurrentLocalization.LocalizationIndex;
|
2018-09-29 15:52:22 -04:00
|
|
|
|
E.Origin.Tell($"IW4M Admin {loc["COMMANDS_UPTIME_TEXT"]} {uptime.Days} {loc["GLOBAL_TIME_DAYS"]}, {uptime.Hours} {loc["GLOBAL_TIME_HOURS"]}, {uptime.Minutes} {loc["GLOBAL_TIME_MINUTES"]}");
|
|
|
|
|
return Task.CompletedTask;
|
2015-03-08 17:20:10 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-19 13:58:01 -04:00
|
|
|
|
public class CListAdmins : Command
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2017-11-15 16:04:13 -05:00
|
|
|
|
public CListAdmins() :
|
2019-03-24 22:34:20 -04:00
|
|
|
|
base("admins", Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_ADMINS_DESC"], "a", EFClient.Permission.User, false)
|
2017-11-15 16:04:13 -05:00
|
|
|
|
{ }
|
2015-03-08 17:20:10 -04:00
|
|
|
|
|
2018-06-26 21:17:24 -04:00
|
|
|
|
public static string OnlineAdmins(Server S)
|
|
|
|
|
{
|
2018-11-05 22:01:29 -05:00
|
|
|
|
var onlineAdmins = S.GetClientsAsList()
|
2019-03-24 22:34:20 -04:00
|
|
|
|
.Where(p => p.Level > EFClient.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) :
|
|
|
|
|
Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_ADMINS_NONE"];
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-29 15:52:22 -04:00
|
|
|
|
public override Task ExecuteAsync(GameEvent E)
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2018-06-26 21:17:24 -04:00
|
|
|
|
foreach (string line in OnlineAdmins(E.Owner).Split(Environment.NewLine))
|
2017-05-27 00:22:50 -04:00
|
|
|
|
{
|
2018-09-29 15:52:22 -04:00
|
|
|
|
var _ = E.Message.IsBroadcastCommand() ? 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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-19 13:58:01 -04:00
|
|
|
|
public class CLoadMap : Command
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2017-11-15 16:04:13 -05:00
|
|
|
|
public CLoadMap() :
|
2019-03-24 22:34:20 -04:00
|
|
|
|
base("map", Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_MAP_DESC"], "m", EFClient.Permission.Administrator, false, new CommandArgument[]
|
2017-11-15 16:04:13 -05:00
|
|
|
|
{
|
|
|
|
|
new CommandArgument()
|
|
|
|
|
{
|
2018-05-05 16:36:26 -04:00
|
|
|
|
Name = Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_ARGS_MAP"],
|
2017-11-15 16:04:13 -05:00
|
|
|
|
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
|
|
|
|
{
|
|
|
|
|
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)
|
|
|
|
|
{
|
2018-09-29 15:52:22 -04:00
|
|
|
|
E.Owner.Broadcast($"{Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_MAP_SUCCESS"]} ^5{m.Alias}");
|
2018-05-14 13:55:10 -04:00
|
|
|
|
await Task.Delay(5000);
|
2017-05-26 18:49:27 -04:00
|
|
|
|
await E.Owner.LoadMap(m.Name);
|
2015-03-08 17:20:10 -04:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-29 15:52:22 -04:00
|
|
|
|
E.Owner.Broadcast($"{Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_MAP_UKN"]} ^5{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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-19 13:58:01 -04:00
|
|
|
|
public class CFindPlayer : Command
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2017-11-15 16:04:13 -05:00
|
|
|
|
public CFindPlayer() :
|
2019-03-24 22:34:20 -04:00
|
|
|
|
base("find", Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_FIND_DESC"], "f", EFClient.Permission.Administrator, false, new CommandArgument[]
|
2017-11-15 16:04:13 -05:00
|
|
|
|
{
|
|
|
|
|
new CommandArgument()
|
|
|
|
|
{
|
2018-05-05 16:36:26 -04:00
|
|
|
|
Name = Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_ARGS_PLAYER"],
|
2017-11-15 16:04:13 -05:00
|
|
|
|
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
|
|
|
|
{
|
2018-04-21 18:18:20 -04:00
|
|
|
|
if (E.Data.Length < 3)
|
|
|
|
|
{
|
2018-09-29 15:52:22 -04:00
|
|
|
|
E.Origin.Tell(Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_FIND_MIN"]);
|
2018-04-21 18:18:20 -04:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-08 02:44:42 -04:00
|
|
|
|
IList<EFClient> db_players = (await (E.Owner.Manager.GetClientService() as ClientService)
|
2018-10-15 20:51:04 -04:00
|
|
|
|
.FindClientsByIdentifier(E.Data))
|
2018-02-15 23:01:28 -05:00
|
|
|
|
.OrderByDescending(p => p.LastConnection)
|
|
|
|
|
.ToList();
|
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
|
|
|
|
{
|
2018-09-29 15:52:22 -04:00
|
|
|
|
E.Origin.Tell(Utilities.CurrentLocalization.LocalizationIndex["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-08-03 22:11:58 -04:00
|
|
|
|
string localizedLevel = Utilities.CurrentLocalization.LocalizationIndex[$"GLOBAL_PERMISSION_{P.Level.ToString().ToUpper()}"];
|
2018-02-11 20:17:20 -05:00
|
|
|
|
// they're not going by another alias
|
|
|
|
|
string msg = P.Name.ToLower().Contains(E.Data.ToLower()) ?
|
2018-08-03 22:11:58 -04:00
|
|
|
|
$"[^3{P.Name}^7] [^3@{P.ClientId}^7] - [{ Utilities.ConvertLevelToColor(P.Level, localizedLevel)}^7] - {P.IPAddressString} | last seen {Utilities.GetTimePassed(P.LastConnection)}" :
|
2018-09-11 15:28:37 -04:00
|
|
|
|
$"({P.AliasLink.Children.FirstOrDefault(a => a.Name.ToLower().Contains(E.Data.ToLower()))?.Name})->[^3{P.Name}^7] [^3@{P.ClientId}^7] - [{ Utilities.ConvertLevelToColor(P.Level, localizedLevel)}^7] - {P.IPAddressString} | 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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-19 13:58:01 -04:00
|
|
|
|
public class CListRules : Command
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2017-11-15 16:04:13 -05:00
|
|
|
|
public CListRules() :
|
2019-03-24 22:34:20 -04:00
|
|
|
|
base("rules", Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_RULES_DESC"], "r", EFClient.Permission.User, false)
|
2017-11-15 16:04:13 -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
|
|
|
|
{
|
2018-03-18 22:25:11 -04:00
|
|
|
|
if (E.Owner.Manager.GetApplicationSettings().Configuration().GlobalRules?.Count < 1 &&
|
|
|
|
|
E.Owner.ServerConfig.Rules?.Count < 1)
|
2017-05-31 01:31:56 -04:00
|
|
|
|
{
|
2018-09-29 15:52:22 -04:00
|
|
|
|
var _ = E.Message.IsBroadcastCommand() ?
|
|
|
|
|
E.Owner.Broadcast(Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_RULES_NONE"]) :
|
|
|
|
|
E.Origin.Tell(Utilities.CurrentLocalization.LocalizationIndex["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
|
|
|
|
{
|
2018-09-29 15:52:22 -04:00
|
|
|
|
var _ = E.Message.IsBroadcastCommand() ? 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
|
|
|
|
|
2017-06-19 13:58:01 -04:00
|
|
|
|
public class CPrivateMessage : Command
|
2015-03-09 16:11:09 -04:00
|
|
|
|
{
|
2017-11-15 16:04:13 -05:00
|
|
|
|
public CPrivateMessage() :
|
2019-03-24 22:34:20 -04:00
|
|
|
|
base("privatemessage", Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_PM_DESC"], "pm", EFClient.Permission.User, true, new CommandArgument[]
|
2017-11-15 16:04:13 -05:00
|
|
|
|
{
|
|
|
|
|
new CommandArgument()
|
|
|
|
|
{
|
2018-05-05 16:36:26 -04:00
|
|
|
|
Name = Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_ARGS_PLAYER"],
|
2017-11-15 16:04:13 -05:00
|
|
|
|
Required = true
|
|
|
|
|
},
|
|
|
|
|
new CommandArgument()
|
|
|
|
|
{
|
2018-05-05 16:36:26 -04:00
|
|
|
|
Name = Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_ARGS_MESSAGE"],
|
2017-11-15 16:04:13 -05:00
|
|
|
|
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
|
|
|
|
|
2018-05-08 00:58:46 -04:00
|
|
|
|
|
2017-06-19 13:58:01 -04:00
|
|
|
|
public class CFlag : Command
|
2015-03-23 23:01:05 -04:00
|
|
|
|
{
|
2017-11-15 16:04:13 -05:00
|
|
|
|
public CFlag() :
|
2019-03-24 22:34:20 -04:00
|
|
|
|
base("flag", Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_FLAG_DESC"], "fp", EFClient.Permission.Moderator, true, new CommandArgument[]
|
2017-11-15 16:04:13 -05:00
|
|
|
|
{
|
|
|
|
|
new CommandArgument()
|
|
|
|
|
{
|
2018-05-05 16:36:26 -04:00
|
|
|
|
Name = Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_ARGS_PLAYER"],
|
2017-11-15 16:04:13 -05:00
|
|
|
|
Required = true
|
|
|
|
|
},
|
|
|
|
|
new CommandArgument()
|
|
|
|
|
{
|
2018-05-05 16:36:26 -04:00
|
|
|
|
Name = Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_ARGS_REASON"],
|
2017-11-15 16:04:13 -05:00
|
|
|
|
Required = true
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
{ }
|
2015-03-23 23:01:05 -04:00
|
|
|
|
|
2018-10-02 13:39:08 -04:00
|
|
|
|
public override Task ExecuteAsync(GameEvent E)
|
2015-03-23 23:01:05 -04:00
|
|
|
|
{
|
2018-09-29 15:52:22 -04:00
|
|
|
|
var flagEvent = E.Target.Flag(E.Data, E.Origin);
|
|
|
|
|
|
|
|
|
|
if (E.FailReason == GameEvent.EventFailReason.Permission)
|
2015-03-23 23:01:05 -04:00
|
|
|
|
{
|
2018-09-29 15:52:22 -04:00
|
|
|
|
E.Origin.Tell($"{Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_FLAG_FAIL"]} ^5{E.Target.Name}");
|
2015-03-23 23:01:05 -04:00
|
|
|
|
}
|
|
|
|
|
|
2018-09-29 15:52:22 -04:00
|
|
|
|
else if (E.FailReason == GameEvent.EventFailReason.Invalid)
|
2015-03-23 23:01:05 -04:00
|
|
|
|
{
|
2018-09-29 15:52:22 -04:00
|
|
|
|
E.Origin.Tell($"{Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_FLAG_ALREADYFLAGGED"]}");
|
2015-03-23 23:01:05 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
{
|
2018-09-29 15:52:22 -04:00
|
|
|
|
E.Origin.Tell($"{Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_FLAG_SUCCESS"]} ^5{E.Target.Name}");
|
2015-03-23 23:01:05 -04:00
|
|
|
|
}
|
|
|
|
|
|
2018-10-02 13:39:08 -04:00
|
|
|
|
return Task.CompletedTask;
|
|
|
|
|
|
2015-03-23 23:01:05 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-08 00:58:46 -04:00
|
|
|
|
public class CUnflag : Command
|
|
|
|
|
{
|
|
|
|
|
public CUnflag() :
|
2019-03-24 22:34:20 -04:00
|
|
|
|
base("unflag", Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_UNFLAG_DESC"], "uf", EFClient.Permission.Moderator, true, new CommandArgument[]
|
2018-05-08 00:58:46 -04:00
|
|
|
|
{
|
|
|
|
|
new CommandArgument()
|
|
|
|
|
{
|
|
|
|
|
Name = Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_ARGS_PLAYER"],
|
|
|
|
|
Required = true
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
{ }
|
|
|
|
|
|
2018-09-29 15:52:22 -04:00
|
|
|
|
public override Task ExecuteAsync(GameEvent E)
|
2018-05-08 00:58:46 -04:00
|
|
|
|
{
|
2018-09-29 15:52:22 -04:00
|
|
|
|
var unflagEvent = E.Target.Unflag(E.Data, E.Origin);
|
|
|
|
|
|
|
|
|
|
if (unflagEvent.FailReason == GameEvent.EventFailReason.Permission)
|
2018-05-08 00:58:46 -04:00
|
|
|
|
{
|
2018-09-29 15:52:22 -04:00
|
|
|
|
E.Origin.Tell($"{Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_UNFLAG_FAIL"]} ^5{E.Target.Name}");
|
2018-05-08 00:58:46 -04:00
|
|
|
|
}
|
|
|
|
|
|
2018-09-29 15:52:22 -04:00
|
|
|
|
else if (unflagEvent.FailReason == GameEvent.EventFailReason.Invalid)
|
2018-05-08 00:58:46 -04:00
|
|
|
|
{
|
2018-10-03 22:20:49 -04:00
|
|
|
|
E.Origin.Tell(Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_UNFLAG_NOTFLAGGED"]);
|
2018-05-08 00:58:46 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
{
|
2018-10-03 22:20:49 -04:00
|
|
|
|
E.Origin.Tell($"{Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_FLAG_UNFLAG"]} ^5{E.Target.Name}");
|
2018-05-08 00:58:46 -04:00
|
|
|
|
}
|
2018-09-29 15:52:22 -04:00
|
|
|
|
|
|
|
|
|
return Task.CompletedTask;
|
|
|
|
|
// todo: update immediately?
|
2018-05-08 00:58:46 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2017-06-19 13:58:01 -04:00
|
|
|
|
public class CReport : Command
|
2015-03-23 23:01:05 -04:00
|
|
|
|
{
|
2017-11-15 16:04:13 -05:00
|
|
|
|
public CReport() :
|
2019-03-24 22:34:20 -04:00
|
|
|
|
base("report", Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_REPORT_DESC"], "rep", EFClient.Permission.User, true, new CommandArgument[]
|
2017-11-15 16:04:13 -05:00
|
|
|
|
{
|
|
|
|
|
new CommandArgument()
|
|
|
|
|
{
|
2018-05-05 16:36:26 -04:00
|
|
|
|
Name = Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_ARGS_PLAYER"],
|
2017-11-15 16:04:13 -05:00
|
|
|
|
Required = true
|
|
|
|
|
},
|
|
|
|
|
new CommandArgument()
|
|
|
|
|
{
|
2018-05-05 16:36:26 -04:00
|
|
|
|
Name = Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_ARGS_REASON"],
|
2017-11-15 16:04:13 -05:00
|
|
|
|
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
|
|
|
|
{
|
2018-09-29 15:52:22 -04:00
|
|
|
|
commandEvent.Origin.Tell(Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_REPORT_FAIL_CAMP"]);
|
2018-02-15 23:01:28 -05:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-29 15:52:22 -04:00
|
|
|
|
var reportEvent = commandEvent.Target.Report(commandEvent.Data, commandEvent.Origin);
|
|
|
|
|
|
|
|
|
|
if (reportEvent.FailReason == GameEvent.EventFailReason.Permission)
|
2016-01-16 17:58:24 -05:00
|
|
|
|
{
|
2018-09-29 15:52:22 -04:00
|
|
|
|
commandEvent.Origin.Tell($"{Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_REPORT_FAIL"]} {commandEvent.Target.Name}");
|
2016-01-16 17:58:24 -05:00
|
|
|
|
}
|
|
|
|
|
|
2018-09-29 15:52:22 -04:00
|
|
|
|
else if (reportEvent.FailReason == GameEvent.EventFailReason.Invalid)
|
2015-04-10 00:02:12 -04:00
|
|
|
|
{
|
2018-09-29 15:52:22 -04:00
|
|
|
|
commandEvent.Origin.Tell(Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_REPORT_FAIL_SELF"]);
|
2015-04-10 00:02:12 -04:00
|
|
|
|
}
|
|
|
|
|
|
2018-10-03 22:20:49 -04:00
|
|
|
|
else if (reportEvent.FailReason == GameEvent.EventFailReason.Throttle)
|
|
|
|
|
{
|
|
|
|
|
commandEvent.Origin.Tell(Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_REPORT_FAIL_TOOMANY"]);
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-29 15:52:22 -04:00
|
|
|
|
else if (reportEvent.Failed)
|
2015-03-23 23:01:05 -04:00
|
|
|
|
{
|
2018-09-29 15:52:22 -04:00
|
|
|
|
commandEvent.Origin.Tell(Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_REPORT_FAIL_DUPLICATE"]);
|
2015-03-23 23:01:05 -04:00
|
|
|
|
}
|
|
|
|
|
|
2018-09-29 15:52:22 -04:00
|
|
|
|
else
|
2018-05-24 15:48:57 -04:00
|
|
|
|
{
|
2018-10-02 13:39:08 -04:00
|
|
|
|
// todo: move into server
|
2018-09-29 15:52:22 -04:00
|
|
|
|
Penalty newReport = new Penalty()
|
|
|
|
|
{
|
|
|
|
|
Type = Penalty.PenaltyType.Report,
|
|
|
|
|
Expires = DateTime.UtcNow,
|
|
|
|
|
Offender = commandEvent.Target,
|
|
|
|
|
Offense = commandEvent.Data,
|
|
|
|
|
Punisher = commandEvent.Origin,
|
|
|
|
|
Active = true,
|
|
|
|
|
When = DateTime.UtcNow,
|
|
|
|
|
Link = commandEvent.Target.AliasLink
|
|
|
|
|
};
|
2018-05-24 15:48:57 -04:00
|
|
|
|
|
2018-09-29 15:52:22 -04:00
|
|
|
|
await commandEvent.Owner.Manager.GetPenaltyService().Create(newReport);
|
2018-08-30 21:53:00 -04:00
|
|
|
|
|
2018-09-29 15:52:22 -04:00
|
|
|
|
commandEvent.Origin.Tell(Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_REPORT_SUCCESS"]);
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-19 13:58:01 -04:00
|
|
|
|
public class CListReports : Command
|
2015-03-23 23:01:05 -04:00
|
|
|
|
{
|
2017-11-15 16:04:13 -05:00
|
|
|
|
public CListReports() :
|
2019-03-24 22:34:20 -04:00
|
|
|
|
base("reports", Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_REPORTS_DESC"], "reps", EFClient.Permission.Moderator, false, new CommandArgument[]
|
2017-11-15 16:04:13 -05:00
|
|
|
|
{
|
|
|
|
|
new CommandArgument()
|
|
|
|
|
{
|
2018-05-05 16:36:26 -04:00
|
|
|
|
Name = Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_ARGS_CLEAR"],
|
2017-11-15 16:04:13 -05:00
|
|
|
|
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
|
|
|
|
{
|
2018-05-05 16:36:26 -04:00
|
|
|
|
if (E.Data != null && E.Data.ToLower().Contains(Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_ARGS_CLEAR"]))
|
2015-08-26 01:49:47 -04:00
|
|
|
|
{
|
|
|
|
|
E.Owner.Reports = new List<Report>();
|
2018-09-29 15:52:22 -04:00
|
|
|
|
E.Origin.Tell(Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_REPORTS_CLEAR_SUCCESS"]);
|
|
|
|
|
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)
|
|
|
|
|
{
|
2018-09-29 15:52:22 -04:00
|
|
|
|
E.Origin.Tell(Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_REPORTS_NONE"]);
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-19 13:58:01 -04:00
|
|
|
|
public class CMask : Command
|
2015-04-10 00:02:12 -04:00
|
|
|
|
{
|
2017-11-15 16:04:13 -05:00
|
|
|
|
public CMask() :
|
2019-03-24 22:34:20 -04:00
|
|
|
|
base("mask", Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_MASK_DESC"], "hide", EFClient.Permission.Moderator, false)
|
2017-11-15 16:04:13 -05:00
|
|
|
|
{ }
|
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;
|
2018-09-29 15:52:22 -04:00
|
|
|
|
E.Origin.Tell(Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_MASK_OFF"]);
|
2015-04-10 00:02:12 -04:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
E.Origin.Masked = true;
|
2018-09-29 15:52:22 -04:00
|
|
|
|
E.Origin.Tell(Utilities.CurrentLocalization.LocalizationIndex["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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-19 13:58:01 -04:00
|
|
|
|
public class CListBanInfo : Command
|
2015-04-10 00:02:12 -04:00
|
|
|
|
{
|
2017-11-15 16:04:13 -05:00
|
|
|
|
public CListBanInfo() :
|
2019-03-24 22:34:20 -04:00
|
|
|
|
base("baninfo", Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_BANINFO_DESC"], "bi", EFClient.Permission.Moderator, true, new CommandArgument[]
|
2017-11-15 16:04:13 -05:00
|
|
|
|
{
|
|
|
|
|
new CommandArgument()
|
|
|
|
|
{
|
2018-05-05 16:36:26 -04:00
|
|
|
|
Name = Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_ARGS_PLAYER"],
|
2017-11-16 18:09:19 -05:00
|
|
|
|
Required = true
|
2017-11-15 16:04:13 -05:00
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
{ }
|
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-11-25 20:29:58 -05:00
|
|
|
|
var B = await E.Owner.Manager.GetPenaltyService().GetClientPenaltiesAsync(E.Target.ClientId);
|
2017-05-27 18:08:04 -04:00
|
|
|
|
|
2018-10-15 20:51:04 -04:00
|
|
|
|
var penalty = B.FirstOrDefault(b => b.Type > Penalty.PenaltyType.Kick &&
|
|
|
|
|
(b.Expires == null || b.Expires > DateTime.UtcNow));
|
2017-11-25 20:29:58 -05:00
|
|
|
|
|
|
|
|
|
if (penalty == null)
|
2015-04-10 00:02:12 -04:00
|
|
|
|
{
|
2018-09-29 15:52:22 -04:00
|
|
|
|
E.Origin.Tell(Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_BANINFO_NONE"]);
|
2015-04-10 00:02:12 -04:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-15 20:51:04 -04:00
|
|
|
|
string timeRemaining = penalty.Type == Penalty.PenaltyType.TempBan ? $"({(penalty.Expires.Value - DateTime.UtcNow).TimeSpanText()} remaining)" : "";
|
2018-05-08 00:58:46 -04:00
|
|
|
|
string success = Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_BANINFO_SUCCESS"];
|
2018-04-22 16:04:18 -04:00
|
|
|
|
|
2018-09-29 15:52:22 -04:00
|
|
|
|
E.Origin.Tell($"^1{E.Target.Name} ^7{string.Format(success, penalty.Punisher.Name)} {penalty.Punisher.Name} {timeRemaining}");
|
2015-04-10 00:02:12 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-19 13:58:01 -04:00
|
|
|
|
public class CListAlias : Command
|
2015-04-10 00:02:12 -04:00
|
|
|
|
{
|
2017-11-15 16:04:13 -05:00
|
|
|
|
public CListAlias() :
|
2019-03-24 22:34:20 -04:00
|
|
|
|
base("alias", Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_ALIAS_DESC"], "known", EFClient.Permission.Moderator, true, new CommandArgument[]
|
2017-11-15 16:04:13 -05:00
|
|
|
|
{
|
|
|
|
|
new CommandArgument()
|
|
|
|
|
{
|
2018-05-05 16:36:26 -04:00
|
|
|
|
Name = Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_ARGS_PLAYER"],
|
2017-11-15 16:04:13 -05:00
|
|
|
|
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
|
|
|
|
|
2018-09-29 15:52:22 -04:00
|
|
|
|
E.Target.Tell($"[^3{E.Target}^7]");
|
2017-08-17 19:28:08 -04:00
|
|
|
|
|
2018-05-05 16:36:26 -04:00
|
|
|
|
message.Append($"{Utilities.CurrentLocalization.LocalizationIndex["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();
|
2018-05-05 16:36:26 -04:00
|
|
|
|
message.Append($"{Utilities.CurrentLocalization.LocalizationIndex["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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-19 13:58:01 -04:00
|
|
|
|
public class CExecuteRCON : Command
|
2015-04-10 00:02:12 -04:00
|
|
|
|
{
|
2017-11-15 16:04:13 -05:00
|
|
|
|
public CExecuteRCON() :
|
2019-03-24 22:34:20 -04:00
|
|
|
|
base("rcon", Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_RCON_DESC"], "rcon", EFClient.Permission.Owner, false, new CommandArgument[]
|
2017-11-15 16:04:13 -05:00
|
|
|
|
{
|
|
|
|
|
new CommandArgument()
|
|
|
|
|
{
|
2018-05-05 16:36:26 -04:00
|
|
|
|
Name = Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_ARGS_COMMANDS"],
|
2017-11-15 16:04:13 -05:00
|
|
|
|
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
|
|
|
|
{
|
2018-09-29 15:52:22 -04:00
|
|
|
|
E.Origin.Tell(S.StripColors());
|
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
|
|
|
|
{
|
2018-09-29 15:52:22 -04:00
|
|
|
|
E.Origin.Tell(Utilities.CurrentLocalization.LocalizationIndex["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
|
|
|
|
|
2017-06-19 13:58:01 -04:00
|
|
|
|
public class CPlugins : Command
|
2017-06-12 17:47:31 -04:00
|
|
|
|
{
|
2017-11-15 16:04:13 -05:00
|
|
|
|
public CPlugins() :
|
2019-03-24 22:34:20 -04:00
|
|
|
|
base("plugins", Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_PLUGINS_DESC"], "p", EFClient.Permission.Administrator, false)
|
2017-11-15 16:04:13 -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
|
|
|
|
{
|
2018-09-29 15:52:22 -04:00
|
|
|
|
E.Origin.Tell(Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_PLUGINS_LOADED"]);
|
2017-06-12 17:47:31 -04:00
|
|
|
|
foreach (var P in Plugins.PluginImporter.ActivePlugins)
|
|
|
|
|
{
|
2018-09-29 15:52:22 -04: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
|
|
|
|
}
|
|
|
|
|
}
|
2017-08-17 19:28:08 -04:00
|
|
|
|
|
|
|
|
|
public class CIP : Command
|
|
|
|
|
{
|
2017-11-15 16:04:13 -05:00
|
|
|
|
public CIP() :
|
2019-03-24 22:34:20 -04:00
|
|
|
|
base("getexternalip", Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_IP_DESC"], "ip", EFClient.Permission.User, false)
|
2017-11-15 16:04:13 -05:00
|
|
|
|
{ }
|
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
|
|
|
|
{
|
2018-09-29 15:52:22 -04:00
|
|
|
|
E.Origin.Tell($"{Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_IP_SUCCESS"]} ^5{E.Origin.IPAddressString}");
|
|
|
|
|
return Task.CompletedTask;
|
2017-08-17 19:28:08 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-02-10 01:26:38 -05:00
|
|
|
|
|
|
|
|
|
public class CPruneAdmins : Command
|
|
|
|
|
{
|
2019-03-24 22:34:20 -04:00
|
|
|
|
public CPruneAdmins() : base("prune", Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_PRUNE_DESC"], "pa", EFClient.Permission.Owner, false, new CommandArgument[]
|
2018-02-10 01:26:38 -05:00
|
|
|
|
{
|
|
|
|
|
new CommandArgument()
|
|
|
|
|
{
|
2018-05-05 16:36:26 -04:00
|
|
|
|
Name = Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_ARGS_INACTIVE"],
|
2018-02-10 01:26:38 -05:00
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
inactiveDays = Int32.Parse(E.Data);
|
|
|
|
|
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)
|
|
|
|
|
{
|
2018-09-29 15:52:22 -04:00
|
|
|
|
E.Origin.Tell(Utilities.CurrentLocalization.LocalizationIndex["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
|
2019-03-24 22:34:20 -04:00
|
|
|
|
.Where(c => c.Level > EFClient.Permission.Flagged && c.Level <= EFClient.Permission.Moderator)
|
2018-02-10 01:26:38 -05:00
|
|
|
|
.Where(c => c.LastConnection < lastActive)
|
|
|
|
|
.ToListAsync();
|
2019-03-24 22:34:20 -04:00
|
|
|
|
inactiveUsers.ForEach(c => c.Level = EFClient.Permission.User);
|
2018-02-10 01:26:38 -05:00
|
|
|
|
await context.SaveChangesAsync();
|
|
|
|
|
}
|
2018-09-29 15:52:22 -04:00
|
|
|
|
E.Origin.Tell($"^5{inactiveUsers.Count} ^7{Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_PRUNE_SUCCESS"]}");
|
2018-03-06 02:22:19 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-04 15:38:34 -04:00
|
|
|
|
public class CSetPassword : Command
|
|
|
|
|
{
|
2019-03-24 22:34:20 -04:00
|
|
|
|
public CSetPassword() : base("setpassword", Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_SETPASSWORD_DESC"], "sp", EFClient.Permission.Moderator, false, new CommandArgument[]
|
2018-04-04 15:38:34 -04:00
|
|
|
|
{
|
|
|
|
|
new CommandArgument()
|
|
|
|
|
{
|
2018-05-05 16:36:26 -04:00
|
|
|
|
Name = Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_ARGS_PASSWORD"],
|
2018-04-04 15:38:34 -04:00
|
|
|
|
Required = true
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
{ }
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
2018-09-29 15:52:22 -04:00
|
|
|
|
E.Origin.Tell(Utilities.CurrentLocalization.LocalizationIndex["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];
|
|
|
|
|
|
2018-04-05 00:38:45 -04:00
|
|
|
|
// update the password for the client in privileged
|
2018-04-26 02:13:04 -04:00
|
|
|
|
E.Owner.Manager.GetPrivilegedClients()[E.Origin.ClientId].Password = hashedPassword[0];
|
|
|
|
|
E.Owner.Manager.GetPrivilegedClients()[E.Origin.ClientId].PasswordSalt = hashedPassword[1];
|
2018-04-05 00:38:45 -04:00
|
|
|
|
|
2018-04-04 15:38:34 -04:00
|
|
|
|
await E.Owner.Manager.GetClientService().Update(E.Origin);
|
2018-09-29 15:52:22 -04:00
|
|
|
|
E.Origin.Tell(Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_PASSWORD_SUCCESS"]);
|
2018-04-04 15:38:34 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-02 01:25:06 -04:00
|
|
|
|
public class CKillServer : Command
|
2018-03-06 02:22:19 -05:00
|
|
|
|
{
|
2019-03-24 22:34:20 -04:00
|
|
|
|
public CKillServer() : base("killserver", "kill the game server", "kill", EFClient.Permission.Administrator, false)
|
2018-03-06 02:22:19 -05:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-06 16:31:05 -04:00
|
|
|
|
public override async Task ExecuteAsync(GameEvent E)
|
2018-03-06 02:22:19 -05:00
|
|
|
|
{
|
2018-11-05 22:01:29 -05:00
|
|
|
|
if (E.Owner.ServerConfig.ManualLogPath != null)
|
2018-05-05 16:36:26 -04:00
|
|
|
|
{
|
2018-11-05 22:01:29 -05:00
|
|
|
|
using (var wc = new WebClient())
|
2018-05-05 16:36:26 -04:00
|
|
|
|
{
|
2018-11-05 22:01:29 -05:00
|
|
|
|
E.Owner.RestartRequested = true;
|
|
|
|
|
var response = await wc.DownloadStringTaskAsync(new Uri($"{E.Owner.ServerConfig.ManualLogPath}/restart"));
|
2018-05-05 16:36:26 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-06 02:22:19 -05:00
|
|
|
|
else
|
|
|
|
|
{
|
2018-11-05 22:01:29 -05:00
|
|
|
|
var gameserverProcesses = System.Diagnostics.Process.GetProcessesByName("iw4x");
|
|
|
|
|
|
|
|
|
|
System.Diagnostics.Process currentProcess = null;
|
|
|
|
|
|
|
|
|
|
foreach (var p in gameserverProcesses)
|
2018-03-06 02:22:19 -05:00
|
|
|
|
{
|
2018-11-05 22:01:29 -05:00
|
|
|
|
string cmdLine = Utilities.GetCommandLine(p.Id);
|
|
|
|
|
|
|
|
|
|
var regex = Regex.Match(cmdLine, @".*((?:\+set|\+) net_port) +([0-9]+).*");
|
|
|
|
|
|
|
|
|
|
if (regex.Success && Int32.Parse(regex.Groups[2].Value) == E.Owner.GetPort())
|
2018-03-06 02:22:19 -05:00
|
|
|
|
{
|
2018-11-05 22:01:29 -05:00
|
|
|
|
currentProcess = p;
|
2018-03-06 02:22:19 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-05 22:01:29 -05:00
|
|
|
|
|
|
|
|
|
if (currentProcess == null)
|
2018-03-06 02:22:19 -05:00
|
|
|
|
{
|
2018-11-05 22:01:29 -05:00
|
|
|
|
E.Origin.Tell("Could not find running/stalled instance of IW4x");
|
2018-03-06 02:22:19 -05:00
|
|
|
|
}
|
|
|
|
|
|
2018-11-05 22:01:29 -05:00
|
|
|
|
else
|
2018-03-06 02:22:19 -05:00
|
|
|
|
{
|
2018-11-05 22:01:29 -05:00
|
|
|
|
// attempt to kill it natively
|
2018-03-06 02:22:19 -05:00
|
|
|
|
try
|
|
|
|
|
{
|
2018-11-05 22:01:29 -05:00
|
|
|
|
if (!E.Owner.Throttled)
|
|
|
|
|
{
|
|
|
|
|
#if !DEBUG
|
|
|
|
|
await E.Owner.ExecuteCommandAsync("quit");
|
|
|
|
|
#endif
|
|
|
|
|
}
|
2018-03-06 02:22:19 -05:00
|
|
|
|
}
|
2018-11-05 22:01:29 -05:00
|
|
|
|
|
|
|
|
|
catch (Exceptions.NetworkException)
|
2018-03-06 02:22:19 -05:00
|
|
|
|
{
|
2018-11-05 22:01:29 -05:00
|
|
|
|
E.Origin.Tell("Unable to cleanly shutdown server, forcing");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!currentProcess.HasExited)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
currentProcess.Kill();
|
|
|
|
|
E.Origin.Tell("Successfully killed server process");
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
E.Origin.Tell("Could not kill server process");
|
|
|
|
|
E.Owner.Logger.WriteDebug("Unable to kill process");
|
|
|
|
|
E.Owner.Logger.WriteDebug($"Exception: {e.Message}");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2018-03-06 02:22:19 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-10-06 12:47:14 -04:00
|
|
|
|
|
2018-11-05 22:01:29 -05:00
|
|
|
|
return;
|
|
|
|
|
}
|
2018-02-10 01:26:38 -05:00
|
|
|
|
}
|
2018-05-05 16:36:26 -04:00
|
|
|
|
}
|
2018-04-14 00:51:38 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class CPing : Command
|
|
|
|
|
{
|
2019-03-24 22:34:20 -04:00
|
|
|
|
public CPing() : base("ping", Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_PING_DESC"], "pi", EFClient.Permission.User, false, new CommandArgument[]
|
2018-04-14 00:51:38 -04:00
|
|
|
|
{
|
|
|
|
|
new CommandArgument()
|
|
|
|
|
{
|
2018-05-05 16:36:26 -04:00
|
|
|
|
Name = Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_ARGS_PLAYER"],
|
2018-04-14 00:51:38 -04:00
|
|
|
|
Required = false
|
|
|
|
|
}
|
2018-04-24 18:01:27 -04: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
|
|
|
|
{
|
|
|
|
|
if (E.Message.IsBroadcastCommand())
|
|
|
|
|
{
|
|
|
|
|
if (E.Target == null)
|
2018-11-05 22:01:29 -05:00
|
|
|
|
{
|
2018-09-29 15:52:22 -04:00
|
|
|
|
E.Owner.Broadcast($"{E.Origin.Name}'s {Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_PING_TARGET"]} ^5{E.Origin.Ping}^7ms");
|
2018-11-05 22:01:29 -05:00
|
|
|
|
}
|
2018-04-14 00:51:38 -04:00
|
|
|
|
else
|
2018-11-05 22:01:29 -05:00
|
|
|
|
{
|
2018-09-29 15:52:22 -04:00
|
|
|
|
E.Owner.Broadcast($"{E.Target.Name}'s {Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_PING_TARGET"]} ^5{E.Target.Ping}^7ms");
|
2018-11-05 22:01:29 -05:00
|
|
|
|
}
|
2018-04-14 00:51:38 -04:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (E.Target == null)
|
2018-11-05 22:01:29 -05:00
|
|
|
|
{
|
2018-09-29 15:52:22 -04:00
|
|
|
|
E.Origin.Tell($"{Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_PING_SELF"]} ^5{E.Origin.Ping}^7ms");
|
2018-11-05 22:01:29 -05:00
|
|
|
|
}
|
2018-04-14 00:51:38 -04:00
|
|
|
|
else
|
2018-11-05 22:01:29 -05:00
|
|
|
|
{
|
2018-09-29 15:52:22 -04:00
|
|
|
|
E.Origin.Tell($"{E.Target.Name}'s {Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_PING_TARGET"]} ^5{E.Target.Ping}^7ms");
|
2018-11-05 22:01:29 -05:00
|
|
|
|
}
|
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
|
|
|
|
|
|
|
|
|
public class CSetGravatar : Command
|
|
|
|
|
{
|
2019-03-24 22:34:20 -04:00
|
|
|
|
public CSetGravatar() : base("setgravatar", Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_GRAVATAR_DESC"], "sg", EFClient.Permission.User, false, new CommandArgument[]
|
2018-06-02 00:48:10 -04:00
|
|
|
|
{
|
|
|
|
|
new CommandArgument()
|
|
|
|
|
{
|
|
|
|
|
Name = Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_ARGS_GRAVATAR"],
|
|
|
|
|
Required = true
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
public override async Task ExecuteAsync(GameEvent E)
|
|
|
|
|
{
|
|
|
|
|
using (var ctx = new DatabaseContext())
|
|
|
|
|
{
|
|
|
|
|
var iqMeta = from meta in ctx.EFMeta
|
|
|
|
|
where meta.ClientId == E.Origin.ClientId
|
|
|
|
|
where meta.Key == "GravatarEmail"
|
|
|
|
|
select meta;
|
|
|
|
|
|
|
|
|
|
var gravatarMeta = await iqMeta.FirstOrDefaultAsync();
|
|
|
|
|
|
|
|
|
|
// gravatar meta has never been added
|
|
|
|
|
if (gravatarMeta == null)
|
|
|
|
|
{
|
|
|
|
|
using (var md5 = MD5.Create())
|
|
|
|
|
{
|
|
|
|
|
gravatarMeta = new EFMeta()
|
|
|
|
|
{
|
|
|
|
|
Active = true,
|
|
|
|
|
ClientId = E.Origin.ClientId,
|
|
|
|
|
Key = "GravatarEmail",
|
|
|
|
|
Value = string.Concat(md5.ComputeHash(E.Data.ToLower().Select(d => Convert.ToByte(d)).ToArray())
|
|
|
|
|
.Select(h => h.ToString("x2"))),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
ctx.EFMeta.Add(gravatarMeta);
|
|
|
|
|
await ctx.SaveChangesAsync();
|
2018-09-29 15:52:22 -04:00
|
|
|
|
E.Origin.Tell(Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_GRAVATAR_SUCCESS_NEW"]);
|
2018-06-02 00:48:10 -04:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ctx.EFMeta.Update(gravatarMeta);
|
|
|
|
|
using (var md5 = MD5.Create())
|
|
|
|
|
{
|
|
|
|
|
gravatarMeta.Value = string.Concat(md5.ComputeHash(E.Data.ToLower().Select(d => Convert.ToByte(d)).ToArray())
|
|
|
|
|
.Select(h => h.ToString("x2")));
|
|
|
|
|
gravatarMeta.Updated = DateTime.UtcNow;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await ctx.SaveChangesAsync();
|
2018-09-29 15:52:22 -04:00
|
|
|
|
E.Origin.Tell(Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_GRAVATAR_SUCCESS_UPDATE"]);
|
2018-06-02 00:48:10 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-06-02 22:21:01 -04:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Retrieves the next map in rotation
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class CNextMap : Command
|
|
|
|
|
{
|
2019-03-24 22:34:20 -04:00
|
|
|
|
public CNextMap() : base("nextmap", Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_NEXTMAP_DESC"], "nm", EFClient.Permission.User, false) { }
|
2018-06-02 22:21:01 -04:00
|
|
|
|
public static async Task<string> GetNextMap(Server s)
|
|
|
|
|
{
|
|
|
|
|
string mapRotation = (await s.GetDvarAsync<string>("sv_mapRotation")).Value.ToLower();
|
|
|
|
|
var regexMatches = Regex.Matches(mapRotation, @"(gametype +([a-z]{1,4}))? *map ([a-z|_]+)", 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)
|
|
|
|
|
{
|
|
|
|
|
return $"{Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_NEXTMAP_SUCCESS"]} ^5{s.CurrentMap.Alias}/{Utilities.GetLocalizedGametype(s.Gametype)}";
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-02 22:21:01 -04:00
|
|
|
|
// the current map is not in rotation
|
|
|
|
|
if (currentMap.Count() == 0)
|
|
|
|
|
{
|
2018-09-16 18:51:11 -04:00
|
|
|
|
return Utilities.CurrentLocalization.LocalizationIndex["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
|
|
|
|
|
2018-06-02 22:21:01 -04:00
|
|
|
|
nextMap = s.Maps.FirstOrDefault(m => m.Name == nextMapMatch.Groups[3].ToString()) ?? nextMap;
|
|
|
|
|
string nextGametype = nextMapMatch.Groups[2].ToString().Length == 0 ?
|
|
|
|
|
Utilities.GetLocalizedGametype(s.Gametype) :
|
|
|
|
|
Utilities.GetLocalizedGametype(nextMapMatch.Groups[2].ToString());
|
|
|
|
|
|
|
|
|
|
return $"{Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_NEXTMAP_SUCCESS"]} ^5{nextMap.Alias}/{nextGametype}";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override async Task ExecuteAsync(GameEvent E)
|
|
|
|
|
{
|
2018-09-29 15:52:22 -04:00
|
|
|
|
E.Origin.Tell(await GetNextMap(E.Owner));
|
2018-06-02 22:21:01 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-09-29 15:52:22 -04:00
|
|
|
|
}
|