Skip to content

Commit

Permalink
feat: alt version check and update loc
Browse files Browse the repository at this point in the history
  • Loading branch information
kalilistic committed Oct 10, 2023
1 parent 15eb3cc commit 69b6897
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Dalamud.DrunkenToad/Dalamud.DrunkenToad.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
</Reference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Dalamud.Loc" Version="1.1.1" />
<PackageReference Include="Dalamud.Loc" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets>
Expand Down
25 changes: 25 additions & 0 deletions Dalamud.DrunkenToad/Extensions/PluginInterfaceExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

using System;
using System.IO;
using System.Linq;
using Game.Text.SeStringHandling;
using Plugin;

Expand Down Expand Up @@ -54,4 +55,28 @@ public static string PluginBackupDirectory(this DalamudPluginInterface value)
Directory.CreateDirectory(backupsDir);
return backupsDir;
}

/// <summary>
/// Check if different version of plugin is loaded.
/// </summary>
/// <param name="value">dalamud plugin interface.</param>
/// <param name="version">version to check.</param>
/// <returns>Indicator if another version of the plugin is loaded.</returns>
public static bool IsDifferentVersionLoaded(this DalamudPluginInterface value, string version = "Canary")
{
var internalName = value.InternalName;
if (!internalName.EndsWith(version, StringComparison.CurrentCulture))
{
return PluginNotLoaded(value, $"{internalName}{version}");
}

var stableName = internalName.Replace(version, string.Empty);
return PluginNotLoaded(value, stableName);
}

private static bool PluginNotLoaded(DalamudPluginInterface pluginInterface, string pluginName)
{
var plugin = pluginInterface.InstalledPlugins.FirstOrDefault(p => p.Name == pluginName);
return plugin == null || !plugin.IsLoaded;
}
}

0 comments on commit 69b6897

Please sign in to comment.