Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
fix: add a default list json for default check.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Apr 8, 2023
1 parent 8905fa6 commit 822c3cf
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 6 deletions.
3 changes: 3 additions & 0 deletions Resources/defaultList.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[
"RotationSolver.Default"
]
5 changes: 5 additions & 0 deletions RotationSolver.Basic/Configuration/PluginConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,12 @@ public class PluginConfiguration : IPluginConfiguration
public float HealthRatioDot = 1.2f;

public bool InDebug = false;
public bool AutoUpdateLibs = true;
public string[] OtherLibs = new string[0];
public (string, string)[] OtherLibsUrl = new(string, string)[]
{
("ArchiDog1998", "RotationSolver"),
};

public List<TargetingType> TargetingTypes { get; set; } = new List<TargetingType>();
public int TargetingIndex { get; set; } = 0;
Expand Down
3 changes: 2 additions & 1 deletion RotationSolver.sln
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8948C02A-914E-4A51-B1FE-2C608492EBF5}"
ProjectSection(SolutionItems) = preProject
.gitignore = .gitignore
Resources\defaultList.json = Resources\defaultList.json
Directory.Build.props = Directory.Build.props
manifest.json = manifest.json
UpdateDownloads.ts = UpdateDownloads.ts
whitelist.json = whitelist.json
Resources\whiteList.json = Resources\whiteList.json
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RotationSolver.Default", "RotationSolver.Default\RotationSolver.Default.csproj", "{CC7BE595-27DE-4206-AE11-8184E7FCF0CD}"
Expand Down
6 changes: 3 additions & 3 deletions RotationSolver/RotationHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ namespace RotationSolver;

internal static class RotationHelper
{
const string DefaultAssembly = "RotationSolver.Default";
public static string[] AllowedAssembly { get; set; } = new string[0];
public static string[] DefaultAssembly { get; set; } = new string[0];

public static bool IsDefault(this ICustomRotation rotation)
{
var type = rotation.GetType();
if (DefaultAssembly != type.Assembly.GetName().Name) return false;
if (!DefaultAssembly.Contains(type.Assembly.GetName().Name)) return false;
return type.Name.Contains("Default", StringComparison.OrdinalIgnoreCase);
}

Expand All @@ -25,7 +25,7 @@ public static bool IsAllowed(this ICustomRotation rotation, out string name)
}
name = rotation.GetType().Assembly.GetName().Name;

return name == DefaultAssembly || AllowedAssembly.Contains(name);
return DefaultAssembly.Contains(name) || AllowedAssembly.Contains(name);
}

public static Vector4 GetColor(this ICustomRotation rotation)
Expand Down
11 changes: 9 additions & 2 deletions RotationSolver/RotationSolverPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,15 @@ public unsafe RotationSolverPlugin(DalamudPluginInterface pluginInterface)

using (var client = new HttpClient())
{
var bts = client.GetByteArrayAsync("https://raw.githubusercontent.com/ArchiDog1998/RotationSolver/main/whitelist.json");
RotationHelper.AllowedAssembly = JsonConvert.DeserializeObject<string[]>( Encoding.Default.GetString(bts.Result));
try
{
var bts = client.GetByteArrayAsync("https://raw.githubusercontent.com/ArchiDog1998/RotationSolver/main/Recources/whiteList.json");
RotationHelper.AllowedAssembly = JsonConvert.DeserializeObject<string[]>(Encoding.Default.GetString(bts.Result));

client.GetByteArrayAsync("https://raw.githubusercontent.com/ArchiDog1998/RotationSolver/main/Recources/defaultList.json");
RotationHelper.DefaultAssembly = JsonConvert.DeserializeObject<string[]>(Encoding.Default.GetString(bts.Result));
}
catch { }
}
}

Expand Down

0 comments on commit 822c3cf

Please sign in to comment.