Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ internal static IEnumerator<float> PresenceCoroutine()
{
while (true)
{
yield return Timing.WaitForSeconds(60f);
try
{
HttpQuery.Post("https://api.ucserver.it/v3/plugin/ucr/presence", JsonSerializer.Serialize(new PresenceMessage()), "application/json");
Expand All @@ -22,6 +21,7 @@ internal static IEnumerator<float> PresenceCoroutine()
{
LogManager.Error($"Failed to send presence data: {e.Message}");
}
yield return Timing.WaitForSeconds(60f);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions UncomplicatedCustomRoles/Commands/Version.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ public bool Executor(List<string> arguments, ICommandSender sender, out string r
return false;
}

response = $"<size=22><b>UncomplicatedCustomRoles</b></size>\n<size=18>Authors: {Plugin.Instance.Author}\nVersion: {VersionManager.VersionInfo.Name}{(VersionManager.VersionInfo.CustomName is not null ? $" '{VersionManager.VersionInfo.CustomName}'" : string.Empty)} ({Plugin.Instance.Version})\nSource: {VersionManager.VersionInfo.Source} - {VersionManager.VersionInfo.SourceLink ?? string.Empty}\nPre release: {(VersionManager.VersionInfo.PreRelease ? "<color=red>TRUE</color>" : "<color=green>FALSE</color>")}\nForced debug: {(VersionManager.VersionInfo.ForceDebug ? "<color=red>TRUE</color>" : "<color=green>FALSE</color>")}\nHash: {(!VersionManager.CorrectHash ? "<color=red>NOT MATCHING!</color>" : "<color=green>Matching</color>")}</size>";
response = $"<size=22><b>UncomplicatedCustomRoles</b></size>\n<size=18>Authors: {Plugin.Instance.Author}\nVersion: {VersionManager.VersionInfo.Name}{(VersionManager.VersionInfo.CustomName is not null ? $" '{VersionManager.VersionInfo.CustomName}'" : string.Empty)} ({Plugin.Instance.Version})\nSource: {VersionManager.VersionInfo.Source} - {VersionManager.VersionInfo.SourceLink ?? string.Empty}\nPre release: {(VersionManager.VersionInfo.PreRelease != 0 ? "<color=red>TRUE</color>" : "<color=green>FALSE</color>")}\nForced debug: {(VersionManager.VersionInfo.ForceDebug != 0 ? "<color=red>TRUE</color>" : "<color=green>FALSE</color>")}\nHash: {(!VersionManager.CorrectHash ? "<color=red>NOT MATCHING!</color>" : "<color=green>Matching</color>")}</size>";

if (!VersionManager.CorrectHash)
response += "\n\n<size=20><b><color=red>⚠ WARNING!</color></b></size>\n<size=18>You are using a <b>NON-OFFICIAL</b> version of the plugin!\nThis version might contain <b>viruses</b> and it's <b>NOT</b> ours!</size>";

if (VersionManager.VersionInfo.Recall)
if (VersionManager.VersionInfo.Recall != 0)
response += $"\n\n<size=20><b><color=red>⚠ WARNING!</color></b></size>\n<size=18>This version has been <b>RECALLED</b> due to the following reason:\n<size=16>{VersionManager.VersionInfo.RecallReason}</size>\nYou are <b>HIGHLY SUGGESTED</b> to update the plugin to the last stable target: {VersionManager.VersionInfo.RecallTarget} {(VersionManager.VersionInfo.RecallImportant ?? true ? $"\n<color=red>You HAVE TO update it, otherwise bad things will happen!</color>" : string.Empty)}</size>";

return true;
Expand Down
8 changes: 4 additions & 4 deletions UncomplicatedCustomRoles/Manager/NET/VersionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ internal class VersionInfo
public string? CustomName { get; }

[JsonPropertyName("pre_release")]
public bool PreRelease { get; }
public int PreRelease { get; }

[JsonPropertyName("force_debug")]
public bool ForceDebug { get; }
public int ForceDebug { get; }

[JsonPropertyName("message")]
public string Message { get; }

[JsonPropertyName("recall")]
public bool Recall { get; }
public int Recall { get; }

[JsonPropertyName("recall_target")]
public string? RecallTarget { get; }
Expand All @@ -53,7 +53,7 @@ internal class VersionInfo
public string Hash { get; }

[JsonConstructor]
public VersionInfo(string name, string source, string? sourceLink, string? customName, bool preRelease, bool forceDebug, string message, bool recall, string? recallTarget, string? recallReason, bool? recallImportant, string hash)
public VersionInfo(string name, string source, string? sourceLink, string? customName, int preRelease, int forceDebug, string message, int recall, string? recallTarget, string? recallReason, bool? recallImportant, string hash)
{
Name = name;
Source = source;
Expand Down
14 changes: 4 additions & 10 deletions UncomplicatedCustomRoles/Manager/VersionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,18 @@ public static void Init()
try
{
string data = Plugin.HttpManager.VersionInfo();
HttpStatusCode code = data.GetStatusCode(out string msg);
if (code is not HttpStatusCode.OK)
{
LogManager.Warn($"Failed to gain the current version info from our central servers: API endpoint says {msg ?? "Message is null"}");
return;
}

data.GetStatusCode(out string msg);
VersionInfo = JsonSerializer.Deserialize<VersionInfo>(data);
if (VersionInfo is null)
{
LogManager.Silent($"Failed to convert API endpoint answer to VersionInfo.\nContent: {msg ?? "Message is null"}");
return;
}

if (VersionInfo.PreRelease)
if (VersionInfo.PreRelease != 0)
{
LogManager.Info($"\nNOTICE!\nYou are currently using the version v{Plugin.Instance.Version}, who's a PRE-RELEASE or an EXPERIMENTAL RELESE of UncomplicatedCustomRoles!\nLatest stable release: {Plugin.HttpManager.LatestVersion}\nNOTE: This is NOT a stable version, so there can be bugs and malfunctions, for this reason we do not recommend use in production.");
if (VersionInfo.ForceDebug && !(Plugin.Instance.Config?.Debug ?? true))
if (VersionInfo.ForceDebug != 0 && !(Plugin.Instance.Config?.Debug ?? true))
{
LogManager.Info("Debug logs have been activated!");
Plugin.Instance.Config.Debug = true;
Expand All @@ -69,7 +63,7 @@ public static void Init()
if (VersionInfo.Message is not null)
LogManager.Info(VersionInfo.Message);

if (VersionInfo.Recall && VersionInfo.RecallTarget is not null && VersionInfo.RecallImportant is not null && VersionInfo.RecallReason is not null)
if (VersionInfo.Recall != 0 && VersionInfo.RecallTarget is not null && VersionInfo.RecallImportant is not null && VersionInfo.RecallReason is not null)
{
RecallMessageSender();
if ((bool)VersionInfo.RecallImportant)
Expand Down
2 changes: 1 addition & 1 deletion UncomplicatedCustomRoles/UncomplicatedCustomRoles.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net48</TargetFramework>
<AssemblyName>UncomplicatedCustomRoles-LabApi</AssemblyName>
<AssemblyName>UncomplicatedCustomRoles</AssemblyName>
<RootNamespace>UncomplicatedCustomRoles</RootNamespace>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion>
Expand Down