Skip to content

Commit

Permalink
Checking null values.
Browse files Browse the repository at this point in the history
  • Loading branch information
Braasileiro committed Feb 8, 2024
1 parent 6b1ad4f commit d09f5b4
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
10 changes: 7 additions & 3 deletions MDRPC/Models/ActivityModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand All @@ -71,4 +75,4 @@ public string GetSmallImageText()
return string.Empty;
return songLevel.GetDifficultyName();
}
}
}
11 changes: 8 additions & 3 deletions MDRPC/Models/CharacterModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
10 changes: 7 additions & 3 deletions MDRPC/Models/ElfinModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@ internal class ElfinModel
{
public static string GetName()
{
return GlobalDataBase
var entity = GlobalDataBase
.dbConfig
.m_ConfigDic["elfin"]
.Cast<DBConfigElfin>()
.GetLocal()
.GetInfoByIndex(DataHelper.selectedElfinIndex)
.name;
.GetInfoByIndex(DataHelper.selectedElfinIndex);

if (entity != null)
return entity.name;

return null;
}
}
5 changes: 3 additions & 2 deletions MDRPC/Properties/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ internal static class Discord
// Unknown
public const string UnknownSong = "Unknown Song";
public const string UnknownAuthor = "Unknown Author";
}
}
public const string UnknownCharacter = "Unknown Character";
}
}

0 comments on commit d09f5b4

Please sign in to comment.