public override async Task ExecuteAsync(GameEvent gameEvent) { var match = Regex.Match(gameEvent.Data.Trim(), ArgumentRegexPattern, RegexOptions.Compiled | RegexOptions.IgnoreCase); if (!match.Success) { gameEvent.Origin.Tell(Syntax); return; } string map; string gametype; if (match.Groups.Count > 3) { map = match.Groups[2].ToString(); gametype = match.Groups[4].ToString(); } else { map = match.Groups[1].ToString(); gametype = match.Groups[3].ToString(); } var matchingMaps = gameEvent.Owner.FindMap(map); var matchingGametypes = _defaultSettings.FindGametype(gametype, gameEvent.Owner.GameName); if (matchingMaps.Count > 1) { gameEvent.Origin.Tell(_translationLookup["COMMANDS_MAG_MULTIPLE_MAPS"]); foreach (var matchingMap in matchingMaps) { gameEvent.Origin.Tell( $"[(Color::Yellow){matchingMap.Alias}(Color::White)] [(Color::Yellow){matchingMap.Name}(Color::White)]"); } return; } if (matchingGametypes.Count > 1) { gameEvent.Origin.Tell(_translationLookup["COMMANDS_MAG_MULTIPLE_GAMETYPES"]); foreach (var matchingGametype in matchingGametypes) { gameEvent.Origin.Tell( $"[(Color::Yellow){matchingGametype.Alias}(Color::White)] [(Color::Yellow){matchingGametype.Name}(Color::White)]"); } return; } map = matchingMaps.FirstOrDefault()?.Name ?? map; gametype = matchingGametypes.FirstOrDefault()?.Name ?? gametype; var hasMatchingGametype = matchingGametypes.Any(); _logger.LogDebug("Changing map to {Map} and gametype {Gametype}", map, gametype); await gameEvent.Owner.SetDvarAsync("g_gametype", gametype); gameEvent.Owner.Broadcast(_translationLookup["COMMANDS_MAP_SUCCESS"].FormatExt(map)); await Task.Delay(gameEvent.Owner.Manager.GetApplicationSettings().Configuration().MapChangeDelaySeconds); switch (gameEvent.Owner.GameName) { case Server.Game.IW5: await gameEvent.Owner.ExecuteCommandAsync( $"load_dsr {(hasMatchingGametype ? gametype.ToUpper() + "_default" : gametype)}"); await gameEvent.Owner.ExecuteCommandAsync($"map {map}"); break; case Server.Game.T6: await gameEvent.Owner.ExecuteCommandAsync($"exec {gametype}.cfg"); await gameEvent.Owner.ExecuteCommandAsync($"map {map}"); break; default: await gameEvent.Owner.ExecuteCommandAsync($"map {map}"); break; } }