diff --git a/src/Artemis.Plugins.Games.LeagueOfLegends/Artemis.Plugins.Games.LeagueOfLegends.Module/InGameApi/DataModels/PlayerDataModel.cs b/src/Artemis.Plugins.Games.LeagueOfLegends/Artemis.Plugins.Games.LeagueOfLegends.Module/InGameApi/DataModels/PlayerDataModel.cs index ef7f2bd..6b2df11 100644 --- a/src/Artemis.Plugins.Games.LeagueOfLegends/Artemis.Plugins.Games.LeagueOfLegends.Module/InGameApi/DataModels/PlayerDataModel.cs +++ b/src/Artemis.Plugins.Games.LeagueOfLegends/Artemis.Plugins.Games.LeagueOfLegends.Module/InGameApi/DataModels/PlayerDataModel.cs @@ -3,8 +3,8 @@ using Artemis.Plugins.Games.LeagueOfLegends.Module.InGameApi.DataModels.Enums; using Artemis.Plugins.Games.LeagueOfLegends.Module.InGameApi.GameDataModels; using Artemis.Plugins.Games.LeagueOfLegends.Module.Utils; -using System; using System.Diagnostics.CodeAnalysis; +using System.Linq; using SummonerSpell = Artemis.Plugins.Games.LeagueOfLegends.Module.InGameApi.DataModels.Enums.SummonerSpell; using ChampionEnum = Artemis.Plugins.Games.LeagueOfLegends.Module.InGameApi.DataModels.Enums.Champion; using Rune = Artemis.Plugins.Games.LeagueOfLegends.Module.InGameApi.DataModels.Enums.Rune; @@ -70,30 +70,11 @@ public void Update(RootGameData rootGameData) SpellF = ParseEnum.TryParseOr(allPlayer.SummonerSpells.SummonerSpellTwo?.RawDisplayName, SummonerSpell.Unknown); } - private static bool TryFindActivePlayer(RootGameData rootGameData, [NotNullWhen(returnValue: true)] out AllPlayer? allPlayer) + public static bool TryFindActivePlayer(RootGameData rootGameData, [NotNullWhen(returnValue: true)] out AllPlayer? allPlayer) { - allPlayer = null; + allPlayer = rootGameData.AllPlayers.FirstOrDefault(p => p?.SummonerName == rootGameData?.ActivePlayer?.SummonerName); - if (string.IsNullOrWhiteSpace(rootGameData?.ActivePlayer?.SummonerName)) - return false; - - ReadOnlySpan summonerName = rootGameData.ActivePlayer.SummonerName; - - var hashIndex = summonerName.IndexOf('#'); - if (hashIndex == -1) - return false; - - var summonerNameWithoutHash = summonerName[..hashIndex]; - foreach (var player in rootGameData.AllPlayers) - { - if (summonerNameWithoutHash.Equals(player.SummonerName, StringComparison.OrdinalIgnoreCase)) - { - allPlayer = player; - return true; - } - } - - return false; + return allPlayer != null; } } diff --git a/src/Artemis.Plugins.Games.LeagueOfLegends/Artemis.Plugins.Games.LeagueOfLegends.Module/plugin.json b/src/Artemis.Plugins.Games.LeagueOfLegends/Artemis.Plugins.Games.LeagueOfLegends.Module/plugin.json index ad018ee..59a5e38 100644 --- a/src/Artemis.Plugins.Games.LeagueOfLegends/Artemis.Plugins.Games.LeagueOfLegends.Module/plugin.json +++ b/src/Artemis.Plugins.Games.LeagueOfLegends/Artemis.Plugins.Games.LeagueOfLegends.Module/plugin.json @@ -5,7 +5,7 @@ "Icon": "league-of-legends.jpg", "Description": "League Of Legends game and client integration", "Author": "diogotr7", - "Version": "1.0.2", + "Version": "1.0.3", "Main": "Artemis.Plugins.Games.LeagueOfLegends.Module.dll", "Website": "https://artemis-rgb.com/", "Repository": "https://github.com/Artemis-RGB/Artemis.Plugins.Games"