Skip to content

Commit

Permalink
fix nullpo when motdurl is null (TorchAPI#195)
Browse files Browse the repository at this point in the history
* fix nullpo when motdurl is null

* prolly better
  • Loading branch information
ryo0ka authored and Yuri committed Sep 9, 2021
1 parent d045c3c commit 6be14d7
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions Essentials/EssentialsPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -278,13 +278,10 @@ public void SendMotd(MyPlayer player, bool onSessionChanged)
{
long playerId = player.Identity.IdentityId;

var motdUrl = MyGuiSandbox.IsUrlWhitelisted(Config.MotdUrl)
? Config.MotdUrl
: $"https://steamcommunity.com/linkfilter/?url={Config.MotdUrl}";

if (!string.IsNullOrEmpty(Config.MotdUrl) && !Config.NewUserMotdUrl)
{
MyVisualScriptLogicProvider.OpenSteamOverlay(motdUrl, playerId);
var url = MakeUrl(Config.MotdUrl);
MyVisualScriptLogicProvider.OpenSteamOverlay(url, playerId);
return;
}

Expand All @@ -301,7 +298,8 @@ public void SendMotd(MyPlayer player, bool onSessionChanged)

if (!string.IsNullOrEmpty(Config.MotdUrl) && isNewUser && Config.NewUserMotdUrl)
{
MyVisualScriptLogicProvider.OpenSteamOverlay(motdUrl, playerId);
var url = MakeUrl(Config.MotdUrl);
MyVisualScriptLogicProvider.OpenSteamOverlay(url, playerId);
return;
}

Expand All @@ -327,6 +325,12 @@ public void SendMotd(MyPlayer player, bool onSessionChanged)
}
}

static string MakeUrl(string url)
{
if (MyGuiSandbox.IsUrlWhitelisted(url)) return url;
return $"https://steamcommunity.com/linkfilter/?url={url}";
}

static string GetDefaultMotdText()
{
try
Expand Down

0 comments on commit 6be14d7

Please sign in to comment.