mirror of
https://github.com/ACEmulator/ACE
synced 2026-08-17 12:26:06 -04:00
* Switch to System.Text.Json Removed Newtonsoft.Json and DouglasCrockford.JsMin * Update GameConfiguration.cs * Update MasterConfiguration.cs * Update ThreadConfiguration.cs * Update StarterSpell.cs * Update StarterGearFactory.cs * Update Program_Setup.cs * Update LifestonedConverter.cs * Update Program_Setup.cs * Update Program_Setup.cs * Update ACE.Adaptor Shift JSON weenie [de]serialization to System.Text.Json * Update LifestonedConverter.cs * Update StarterGearFactory.cs * Update ACE.Server.csproj * Update ACE.Server.Tests.csproj * Update Program.cs * Update MySqlConfiguration.cs * Update DDDConfiguration.cs * Update ModContainer.cs * Update ModManager.cs * Update ModMetadata.cs * Update ModMetadata.cs
53 lines
2.2 KiB
C#
53 lines
2.2 KiB
C#
using System;
|
|
using System.Text.Json;
|
|
|
|
namespace ACE.Server
|
|
{
|
|
partial class Program
|
|
{
|
|
private static void CheckForServerUpdate()
|
|
{
|
|
log.Info($"Automatic Server version check started...");
|
|
try
|
|
{
|
|
var worldDb = new Database.WorldDatabase();
|
|
var currentVersion = worldDb.GetVersion();
|
|
log.Info($"Current Server Binary: {ServerBuildInfo.FullVersion}");
|
|
|
|
var url = "https://api.github.com/repos/ACEmulator/ACE/releases/latest";
|
|
using var client = new WebClient();
|
|
var html = client.GetStringFromURL(url).Result;
|
|
|
|
var json = JsonSerializer.Deserialize<JsonElement>(html);
|
|
|
|
string tag = json.GetProperty("tag_name").GetString();
|
|
|
|
//Split the tag from "v{version}.{build}" into discrete components - "tag_name": "v1.39.4192"
|
|
Version v = new Version(tag.Remove(0, 1));
|
|
Version currentServerVersion = ServerBuildInfo.GetServerVersion();
|
|
|
|
var versionStatus = v.CompareTo(currentServerVersion);
|
|
// Status returns > 0 if the GitHub version is newer. (0 if the same, or < 0 if older.)
|
|
if (versionStatus > 0)
|
|
{
|
|
log.Warn("There is a newer version of ACE available!");
|
|
log.Warn($"Please visit {json.GetProperty("html_url").GetString()} for more information.");
|
|
|
|
// the Console.Title.Get() only works on Windows...
|
|
#pragma warning disable CA1416 // Validate platform compatibility
|
|
Console.Title += " -- Server Binary Update Available";
|
|
#pragma warning restore CA1416 // Validate platform compatibility
|
|
}
|
|
else
|
|
{
|
|
log.Info($"Latest Server Version is {tag} -- No Update Required!");
|
|
}
|
|
return;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
log.Info($"Unable to continue with Automatic Server Version Check due to the following error: {ex}");
|
|
}
|
|
}
|
|
}
|
|
}
|