diff --git a/MDRPC/Models/ActivityModel.cs b/MDRPC/Models/ActivityModel.cs index 9969ac7..926223d 100644 --- a/MDRPC/Models/ActivityModel.cs +++ b/MDRPC/Models/ActivityModel.cs @@ -55,8 +55,12 @@ public string GetLargeImageText() { if (!isPlaying) return $"{Global.MelonInfo.Name} {Global.MelonInfo.Version} • {playerName} (Lv. {playerLevel})"; - return $"{playerName} (Lv. {playerLevel}) • {playerCharacter} feat. {playerElfin}"; - } + + if (playerElfin != null) + return $"{playerName} (Lv. {playerLevel}) • {playerCharacter} feat. {playerElfin}"; + + return $"{playerName} (Lv. {playerLevel}) • {playerCharacter}"; + } public string GetSmallImage() { @@ -71,4 +75,4 @@ public string GetSmallImageText() return string.Empty; return songLevel.GetDifficultyName(); } -} \ No newline at end of file +} diff --git a/MDRPC/Models/CharacterModel.cs b/MDRPC/Models/CharacterModel.cs index b746d77..367a52e 100644 --- a/MDRPC/Models/CharacterModel.cs +++ b/MDRPC/Models/CharacterModel.cs @@ -20,9 +20,14 @@ public static string GetName() .GetLocal() .GetInfoByIndex(DataHelper.selectedRoleIndex); - if (CosCharacters.Contains(entity.characterName, StringComparer.OrdinalIgnoreCase)) - return $"{entity.cosName} {entity.characterName}"; + if (entity != null) + { + if (CosCharacters.Contains(entity.characterName, StringComparer.OrdinalIgnoreCase)) + return $"{entity.cosName} {entity.characterName}"; - return entity.characterName; + return entity.characterName; + } + + return Constants.Discord.UnknownCharacter; } } diff --git a/MDRPC/Models/ElfinModel.cs b/MDRPC/Models/ElfinModel.cs index 7381ba7..af225e2 100644 --- a/MDRPC/Models/ElfinModel.cs +++ b/MDRPC/Models/ElfinModel.cs @@ -6,12 +6,16 @@ internal class ElfinModel { public static string GetName() { - return GlobalDataBase + var entity = GlobalDataBase .dbConfig .m_ConfigDic["elfin"] .Cast() .GetLocal() - .GetInfoByIndex(DataHelper.selectedElfinIndex) - .name; + .GetInfoByIndex(DataHelper.selectedElfinIndex); + + if (entity != null) + return entity.name; + + return null; } } diff --git a/MDRPC/Properties/Constants.cs b/MDRPC/Properties/Constants.cs index f1a6c7f..55ca414 100644 --- a/MDRPC/Properties/Constants.cs +++ b/MDRPC/Properties/Constants.cs @@ -21,5 +21,6 @@ internal static class Discord // Unknown public const string UnknownSong = "Unknown Song"; public const string UnknownAuthor = "Unknown Author"; - } -} \ No newline at end of file + public const string UnknownCharacter = "Unknown Character"; + } +}