mirror of
https://github.com/Nereziel/cs2-WeaponPaints.git
synced 2026-02-20 03:07:16 +00:00
Merge pull request #90 from daffyyyy/some-changes
!skins thread-safe and checking version
This commit is contained in:
40
Utility.cs
40
Utility.cs
@@ -5,6 +5,7 @@ using MySqlConnector;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using System.Reflection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace WeaponPaints
|
||||
{
|
||||
@@ -107,6 +108,45 @@ namespace WeaponPaints
|
||||
return message;
|
||||
}
|
||||
|
||||
internal static async Task CheckVersion(string version)
|
||||
{
|
||||
using (HttpClient client = new HttpClient())
|
||||
{
|
||||
try
|
||||
{
|
||||
HttpResponseMessage response = await client.GetAsync("https://github.com/Nereziel/cs2-WeaponPaints/blob/main/VERSION");
|
||||
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
string remoteVersion = await response.Content.ReadAsStringAsync();
|
||||
remoteVersion = remoteVersion.Trim();
|
||||
|
||||
int comparisonResult = string.Compare(version, remoteVersion);
|
||||
|
||||
if (comparisonResult < 0)
|
||||
{
|
||||
WeaponPaints.logger!.LogWarning("Plugin is outdated! Check https://github.com/Nereziel/cs2-WeaponPaints");
|
||||
}
|
||||
else if (comparisonResult > 0)
|
||||
{
|
||||
WeaponPaints.logger!.LogInformation("Probably dev version detected");
|
||||
}
|
||||
else
|
||||
{
|
||||
WeaponPaints.logger!.LogInformation("Plugin is up to date");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
WeaponPaints.logger!.LogWarning("Failed to check version");
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal static void ShowAd(string moduleVersion)
|
||||
{
|
||||
Console.WriteLine(" ");
|
||||
|
||||
Reference in New Issue
Block a user