Skip to content

Commit

Permalink
Mod is now toggleable
Browse files Browse the repository at this point in the history
  • Loading branch information
iamwyza committed Feb 3, 2018
1 parent a549101 commit ab56841
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
21 changes: 19 additions & 2 deletions PlayerDataDump/PlayerDataDump.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace PlayerDataDump
/// <summary>
/// Main mod class for PlayerDataDump. Provides the server and version handling.
/// </summary>
public class PlayerDataDump : Mod
public class PlayerDataDump : Mod, ITogglableMod
{
public override int LoadPriority() => 9999;
private readonly WebSocketServer _wss = new WebSocketServer(11420);
Expand All @@ -35,16 +35,23 @@ public static string GetCurrentMods()
/// <returns>Returns the current version. Includes additional text if the current version doesn't match the version of the site.</returns>
public override string GetVersion() => FileVersionInfo.GetVersionInfo(Assembly.GetAssembly(typeof(PlayerDataDump)).Location).FileVersion;

private bool? isCurrent;

public override bool IsCurrent()
{
if (isCurrent != null)
return isCurrent.Value;

try
{
GithubVersionHelper helper = new GithubVersionHelper("iamwyza/HollowKnightRandomizerTracker");
Version currentVersion = new Version(GetVersion());

Version newVersion = new Version(helper.GetVersion());
LogDebug($"Comparing Versions: {newVersion} > {currentVersion}");
return newVersion.CompareTo(currentVersion) <= 0;
isCurrent = newVersion.CompareTo(currentVersion) <= 0;

return isCurrent.Value;
}
catch (Exception ex)
{
Expand Down Expand Up @@ -89,5 +96,15 @@ public override void Initialize()

Log("Initialized PlayerDataDump");
}

/// <summary>
/// Called when the mod is disabled, stops the web socket server and removes the socket services.
/// </summary>
public void Unload()
{
_wss.Stop();
_wss.RemoveWebSocketService("/playerData");
_wss.RemoveWebSocketService("/ProfileStorage");
}
}
}
4 changes: 2 additions & 2 deletions PlayerDataDump/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@
// Build Number
// Revision
//
[assembly: AssemblyVersion("2.4.1.1")]
[assembly: AssemblyFileVersion("2.4.1.1")]
[assembly: AssemblyVersion("2.4.2.1")]
[assembly: AssemblyFileVersion("2.4.2.1")]

0 comments on commit ab56841

Please sign in to comment.