move IW4x parser out of code
add CoD4x parser
This commit is contained in:
parent
29eedea093
commit
f3290cf066
@ -283,6 +283,24 @@ namespace IW4MAdmin.Application
|
||||
config.WebfrontBindUrl = "http://0.0.0.0:1624";
|
||||
await ConfigHandler.Save();
|
||||
}
|
||||
|
||||
foreach (var serverConfig in config.Servers)
|
||||
{
|
||||
if (serverConfig.RConParserVersion == null || serverConfig.EventParserVersion == null)
|
||||
{
|
||||
foreach (var parser in AdditionalRConParsers)
|
||||
{
|
||||
serverConfig.AddRConParser(parser);
|
||||
}
|
||||
|
||||
foreach (var parser in AdditionalEventParsers)
|
||||
{
|
||||
serverConfig.AddEventParser(parser);
|
||||
}
|
||||
|
||||
serverConfig.ModifyParsers();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if (config.Servers.Count == 0)
|
||||
|
@ -13,7 +13,7 @@ namespace IW4MAdmin.Application.EventParsers
|
||||
{
|
||||
Configuration = new DynamicEventParserConfiguration()
|
||||
{
|
||||
GameDirectory = "userraw",
|
||||
GameDirectory = "main",
|
||||
};
|
||||
|
||||
Configuration.Say.Pattern = @"^(say|sayteam);(.{8,32});([0-9]+);(.+);(.*)$";
|
||||
@ -68,7 +68,7 @@ namespace IW4MAdmin.Application.EventParsers
|
||||
|
||||
public IEventParserConfiguration Configuration { get; set; }
|
||||
|
||||
public string Version { get; set; } = "IW4x (v0.6.0)";
|
||||
public string Version { get; set; } = "CoD";
|
||||
|
||||
public virtual GameEvent GetEvent(Server server, string logLine)
|
||||
{
|
||||
@ -215,6 +215,8 @@ namespace IW4MAdmin.Application.EventParsers
|
||||
var regexMatch = Regex.Match(logLine, Configuration.Join.Pattern);
|
||||
if (regexMatch.Success)
|
||||
{
|
||||
bool isBot = regexMatch.Groups[Configuration.Join.GroupMapping[ParserRegex.GroupType.OriginNetworkId]].ToString().Contains("bot");
|
||||
|
||||
return new GameEvent()
|
||||
{
|
||||
Type = GameEvent.EventType.PreConnect,
|
||||
@ -230,7 +232,8 @@ namespace IW4MAdmin.Application.EventParsers
|
||||
NetworkId = regexMatch.Groups[Configuration.Join.GroupMapping[ParserRegex.GroupType.OriginNetworkId]].ToString().ConvertLong(),
|
||||
ClientNumber = Convert.ToInt32(regexMatch.Groups[Configuration.Join.GroupMapping[ParserRegex.GroupType.OriginClientNumber]].ToString()),
|
||||
State = EFClient.ClientState.Connecting,
|
||||
CurrentServer = server
|
||||
CurrentServer = server,
|
||||
IsBot = isBot
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -667,10 +667,10 @@ namespace IW4MAdmin
|
||||
public async Task Initialize()
|
||||
{
|
||||
RconParser = Manager.AdditionalRConParsers
|
||||
.FirstOrDefault(_parser => _parser.Version == ServerConfig.CustomParserVersion);
|
||||
.FirstOrDefault(_parser => _parser.Version == ServerConfig.RConParserVersion);
|
||||
|
||||
EventParser = Manager.AdditionalEventParsers
|
||||
.FirstOrDefault(_parser => _parser.Version == ServerConfig.CustomParserVersion);
|
||||
.FirstOrDefault(_parser => _parser.Version == ServerConfig.EventParserVersion);
|
||||
|
||||
RconParser = RconParser ?? new BaseRConParser();
|
||||
EventParser = EventParser ?? new BaseEventParser();
|
||||
|
@ -19,8 +19,8 @@ namespace IW4MAdmin.Application.RconParsers
|
||||
{
|
||||
CommandPrefixes = new CommandPrefix()
|
||||
{
|
||||
Tell = "tellraw {0} {1}",
|
||||
Say = "sayraw {0}",
|
||||
Tell = "tell {0} {1}",
|
||||
Say = "say {0}",
|
||||
Kick = "clientkick {0} \"{1}\"",
|
||||
Ban = "clientkick {0} \"{1}\"",
|
||||
TempBan = "tempbanclient {0} \"{1}\"",
|
||||
@ -42,7 +42,7 @@ namespace IW4MAdmin.Application.RconParsers
|
||||
Configuration.Status.AddMapping(ParserRegex.GroupType.RConName, 5);
|
||||
Configuration.Status.AddMapping(ParserRegex.GroupType.RConIpAddress, 7);
|
||||
|
||||
Configuration.Dvar.Pattern = "^\"(.+)\" is: \"(.+)\" default: \"(.+)?\"\n(?:latched: \"(.+)?\"\n)? *(.+)$";
|
||||
Configuration.Dvar.Pattern = "^\"(.+)\" is: \"(.+)?\" default: \"(.+)?\"\n(?:latched: \"(.+)?\"\n)? *(.+)$";
|
||||
Configuration.Dvar.AddMapping(ParserRegex.GroupType.RConDvarName, 1);
|
||||
Configuration.Dvar.AddMapping(ParserRegex.GroupType.RConDvarValue, 2);
|
||||
Configuration.Dvar.AddMapping(ParserRegex.GroupType.RConDvarDefaultValue, 3);
|
||||
@ -52,7 +52,7 @@ namespace IW4MAdmin.Application.RconParsers
|
||||
|
||||
public IRConParserConfiguration Configuration { get; set; }
|
||||
|
||||
public string Version { get; set; } = "IW4x (v0.6.0)";
|
||||
public string Version { get; set; } = "CoD";
|
||||
|
||||
public async Task<string[]> ExecuteCommandAsync(Connection connection, string command)
|
||||
{
|
||||
|
@ -38,7 +38,8 @@ Project("{888888A0-9F3D-457C-B088-3A5042F75D52}") = "DiscordWebhook", "DiscordWe
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ScriptPlugins", "ScriptPlugins", "{3F9ACC27-26DB-49FA-BCD2-50C54A49C9FA}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
Plugins\ScriptPlugins\ParserIW3.js = Plugins\ScriptPlugins\ParserIW3.js
|
||||
Plugins\ScriptPlugins\ParserCoD4x.js = Plugins\ScriptPlugins\ParserCoD4x.js
|
||||
Plugins\ScriptPlugins\ParserIW4x.js = Plugins\ScriptPlugins\ParserIW4x.js
|
||||
Plugins\ScriptPlugins\ParserPT6.js = Plugins\ScriptPlugins\ParserPT6.js
|
||||
Plugins\ScriptPlugins\ParserTeknoMW3.js = Plugins\ScriptPlugins\ParserTeknoMW3.js
|
||||
Plugins\ScriptPlugins\SharedGUIDKick.js = Plugins\ScriptPlugins\SharedGUIDKick.js
|
||||
|
30
Plugins/ScriptPlugins/ParserCoD4x.js
Normal file
30
Plugins/ScriptPlugins/ParserCoD4x.js
Normal file
@ -0,0 +1,30 @@
|
||||
var rconParser;
|
||||
var eventParser;
|
||||
|
||||
var plugin = {
|
||||
author: 'FrenchFry, RaidMax',
|
||||
version: 0.2,
|
||||
name: 'CoD4x Parser',
|
||||
isParser: true,
|
||||
|
||||
onEventAsync: function (gameEvent, server) {
|
||||
},
|
||||
|
||||
onLoadAsync: function (manager) {
|
||||
rconParser = manager.GenerateDynamicRConParser();
|
||||
eventParser = manager.GenerateDynamicEventParser();
|
||||
|
||||
rconParser.Configuration.Dvar.Pattern = '^"(.+)" is: "(.+)?" default: "(.+)?" info: "(.+)?"$';
|
||||
rconParser.Configuration.Dvar.AddMapping(110, 4);
|
||||
rconParser.Version = 'CoD4 X 1.8 win_mingw-x86 build 2055 May 2 2017';
|
||||
|
||||
eventParser.Configuration.GameDirectory = 'main';
|
||||
eventParser.Version = 'CoD4 X 1.8 win_mingw-x86 build 2055 May 2 2017';
|
||||
},
|
||||
|
||||
onUnloadAsync: function () {
|
||||
},
|
||||
|
||||
onTickAsync: function (server) {
|
||||
}
|
||||
};
|
@ -14,15 +14,15 @@ var plugin = {
|
||||
rconParser = manager.GenerateDynamicRConParser();
|
||||
eventParser = manager.GenerateDynamicEventParser();
|
||||
|
||||
rconParser.Configuration.CommandPrefixes.Tell = 'tell {0} {1}';
|
||||
rconParser.Configuration.CommandPrefixes.Say = 'say {0}';
|
||||
rconParser.Configuration.CommandPrefixes.Tell = 'tellraw {0} {1}';
|
||||
rconParser.Configuration.CommandPrefixes.Say = 'sayraw {0}';
|
||||
rconParser.Configuration.CommandPrefixes.Kick = 'clientkick {0} "{1}"';
|
||||
rconParser.Configuration.CommandPrefixes.Ban = 'clientkick {0} "{1}"';
|
||||
rconParser.Configuration.CommandPrefixes.TempBan = 'tempbanclient {0} "{1}"';
|
||||
rconParser.Version = 'CoD4 MP 1.8 build 13620 Thu Oct 04 00:43:04 2007 win-x86';
|
||||
eventParser.Configuration.GameDirectory = 'userraw';
|
||||
|
||||
eventParser.Configuration.GameDirectory = 'main';
|
||||
eventParser.Version = 'CoD4 MP 1.8 build 13620 Thu Oct 04 00:43:04 2007 win-x86';
|
||||
rconParser.Version = 'IW4x (v0.6.0)';
|
||||
eventParser.Version = 'IW4x (v0.6.0)';
|
||||
},
|
||||
|
||||
onUnloadAsync: function () {
|
@ -13,7 +13,8 @@ namespace SharedLibraryCore.Configuration
|
||||
public IList<string> Rules { get; set; }
|
||||
public IList<string> AutoMessages { get; set; }
|
||||
public string ManualLogPath { get; set; }
|
||||
public string CustomParserVersion { get; set; }
|
||||
public string RConParserVersion { get; set; }
|
||||
public string EventParserVersion { get; set; }
|
||||
public int ReservedSlotNumber { get; set; }
|
||||
|
||||
private readonly IList<IRConParser> rconParsers;
|
||||
@ -28,6 +29,27 @@ namespace SharedLibraryCore.Configuration
|
||||
public void AddRConParser(IRConParser parser) => rconParsers.Add(parser);
|
||||
public void AddEventParser(IEventParser parser) => eventParsers.Add(parser);
|
||||
|
||||
public void ModifyParsers()
|
||||
{
|
||||
var loc = Utilities.CurrentLocalization.LocalizationIndex;
|
||||
var parserVersions = rconParsers.Select(_parser => _parser.Version).ToArray();
|
||||
var selection = Utilities.PromptSelection($"{loc["SETUP_SERVER_RCON_PARSER_VERSION"]} ({IPAddress}:{Port})", $"{loc["SETUP_PROMPT_DEFAULT"]} (Call of Duty)", null, parserVersions);
|
||||
|
||||
if (selection.Item1 > 0)
|
||||
{
|
||||
RConParserVersion = selection.Item2;
|
||||
}
|
||||
|
||||
parserVersions = eventParsers.Select(_parser => _parser.Version).ToArray();
|
||||
Console.WriteLine($"{IPAddress}:{Port}");
|
||||
selection = Utilities.PromptSelection($"{loc["SETUP_SERVER_EVENT_PARSER_VERSION"]} ({IPAddress}:{Port})", $"{loc["SETUP_PROMPT_DEFAULT"]} (Call of Duty)", null, parserVersions);
|
||||
|
||||
if (selection.Item1 > 0)
|
||||
{
|
||||
EventParserVersion = selection.Item2;
|
||||
}
|
||||
}
|
||||
|
||||
public IBaseConfiguration Generate()
|
||||
{
|
||||
var loc = Utilities.CurrentLocalization.LocalizationIndex;
|
||||
@ -52,21 +74,7 @@ namespace SharedLibraryCore.Configuration
|
||||
Rules = new List<string>();
|
||||
ReservedSlotNumber = loc["SETUP_SERVER_RESERVEDSLOT"].PromptInt(null, 0, 32);
|
||||
|
||||
var parserVersions = rconParsers.Select(_parser => _parser.Version).ToArray();
|
||||
var selection = Utilities.PromptSelection(loc["SETUP_SERVER_RCON_PARSER_VERSION"], $"{loc["SETUP_PROMPT_DEFAULT"]} (IW4x)", null, parserVersions);
|
||||
|
||||
if (selection.Item1 > 0)
|
||||
{
|
||||
CustomParserVersion = selection.Item2;
|
||||
}
|
||||
|
||||
parserVersions = eventParsers.Select(_parser => _parser.Version).ToArray();
|
||||
selection = Utilities.PromptSelection(loc["SETUP_SERVER_EVENT_PARSER_VERSION"], $"{loc["SETUP_PROMPT_DEFAULT"]} (IW4x)", null, parserVersions);
|
||||
|
||||
if (selection.Item1 > 0)
|
||||
{
|
||||
CustomParserVersion = selection.Item2;
|
||||
}
|
||||
ModifyParsers();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user