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

Commit

Permalink
feat: removed the white list.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Jul 25, 2023
1 parent a4b6289 commit 3a7bdd6
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 201 deletions.
3 changes: 2 additions & 1 deletion Resources/AnimationLockTime.json
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@
"7510": 0.1,
"7511": 0.1,
"7513": 0.6,
"7514": 0.6,
"7514": 0.1,
"7517": 0.6,
"7518": 0.6,
"7519": 0.6,
Expand Down Expand Up @@ -444,6 +444,7 @@
"23284": 0.1,
"23317": 2.1,
"23915": 0.1,
"23986": 2.1,
"24222": 2.1,
"24235": 2.1,
"24283": 0.1,
Expand Down
5 changes: 4 additions & 1 deletion Resources/HostileCastingArea.json
Original file line number Diff line number Diff line change
Expand Up @@ -291,5 +291,8 @@
20428,
21004,
21000,
20996
20996,
8150,
8167,
6893
]
87 changes: 0 additions & 87 deletions Resources/InputConfig.json

This file was deleted.

8 changes: 0 additions & 8 deletions Resources/whitelist.json

This file was deleted.

11 changes: 0 additions & 11 deletions RotationSolver/Commands/RSCommands_Actions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,6 @@ internal static unsafe bool CanDoAnAction(bool isGCD)
internal static uint _lastActionID;
public static void DoAction()
{
//High End bye.
if (DataCenter.InHighEndDuty && !RotationUpdater.RightNowRotation.IsAllowed(out var str))
{
if ((_loop %= 5) == 0)
{
Svc.Toasts.ShowError(string.Format(LocalizationManager.RightLang.HighEndBan, str));
}
_loop++;
return;
}

var wrong = new Random().NextDouble() < Service.Config.MistakeRatio && ActionUpdater.WrongAction != null;
var nextAction = wrong ? ActionUpdater.WrongAction : ActionUpdater.NextAction;
if (nextAction == null) return;
Expand Down
71 changes: 12 additions & 59 deletions RotationSolver/Helpers/RotationHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,6 @@ internal static class RotationHelper

public static List<LoadedAssembly> LoadedCustomRotations { get; } = new List<LoadedAssembly>();

public static string[] AllowedAssembly { get; private set; } = Array.Empty<string>();

public static async Task LoadListAsync()
{
try
{
using var client = new HttpClient();
var response = await client.GetAsync("https://raw.githubusercontent.com/ArchiDog1998/RotationSolver/main/Resources/whitelist.json");
response.EnsureSuccessStatusCode();
var content = await response.Content.ReadAsStringAsync();
AllowedAssembly = JsonConvert.DeserializeObject<string[]>(content);
}
catch (Exception ex)
{
var failed = LocalizationManager.RightLang.WhiteListDownloadingFailed;
failed.ShowWarning(1, RotationSolverPlugin.DownloadLinkPayload);
PluginLog.Log(ex, failed);
}
}

public static AssemblyInfo GetInfo(this Assembly assembly)
{
if (_assemblyInfos.TryGetValue(assembly, out var info))
Expand All @@ -54,40 +34,18 @@ public static AssemblyInfo GetInfo(this Assembly assembly)
return assemblyInfo;
}

public static bool IsAllowed(this ICustomRotation rotation, out string name)
{
name = "Unknown";
if (rotation == null) return false;

var assembly = GetTypeAssembly(rotation);
if (assembly == null) return false;

name = assembly.GetName().Name;
return assembly.IsAllowed();
}

public static bool IsAllowed(this Assembly assembly)
{
if (_assemblyInfos.TryGetValue(assembly, out var info))
{
var assemblyName = $"{info.Name} - {info.Author}";
return AllowedAssembly.Contains(assemblyName);
}
return false;
}

public static Assembly GetTypeAssembly(this ICustomRotation rotation)
{
try
{
return rotation.GetType().Assembly;
}
catch (Exception ex)
{
PluginLog.LogError($"Failed to get assembly for rotation {rotation.GetType().Name}: {ex}");
return null;
}
}
//public static Assembly GetTypeAssembly(this ICustomRotation rotation)
//{
// try
// {
// return rotation.GetType().Assembly;
// }
// catch (Exception ex)
// {
// PluginLog.LogError($"Failed to get assembly for rotation {rotation.GetType().Name}: {ex}");
// return null;
// }
//}

public static Vector4 GetColor(this ICustomRotation rotation)
{
Expand All @@ -96,11 +54,6 @@ public static Vector4 GetColor(this ICustomRotation rotation)
return ImGuiColors.DPSRed;
}

if (!rotation.IsAllowed(out _))
{
return ImGuiColors.DalamudViolet;
}

if (rotation.IsBeta())
{
return ImGuiColors.DalamudOrange;
Expand Down
6 changes: 1 addition & 5 deletions RotationSolver/Localization/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ internal partial class Strings
public string ConfigWindow_HelpItem_EndSpecial { get; set; }
= "To end this special duration before the set time.";
public string ConfigWindow_Helper_SwitchRotation { get; set; } = "Click to switch authors";
public string ConfigWindow_Helper_HighEndWarning { get; set; } = "This <{0}> rotation is not allowed to be used in High-end Duty!";
public string ConfigWindow_Helper_GameVersion { get; set; } = "Game Version";
public string ConfigWindow_Helper_OpenSource { get; set; } = "Open the source code URL";
public string ConfigWindow_Helper_RunCommand { get; set; } = "Click to execute the command";
Expand All @@ -90,7 +89,7 @@ internal partial class Strings
public string ConfigWindow_Events_ShareMacro { get; set; } = "Is Shared";
public string ConfigWindow_Events_RemoveEvent { get; set; } = "Delete Event";
public string ConfigWindow_Events_DutyStart { get; set; } = "Duty Start: ";
public string ConfigWindow_Events_DutyEnd{ get; set; } = "Duty End: ";
public string ConfigWindow_Events_DutyEnd { get; set; } = "Duty End: ";
public string ConfigWindow_Params_Description { get; set; } = "In this window, you can set the parameters about the using way of actions.";

public string ConfigWindow_Param_UseOverlayWindow { get; set; } = "Display Top Overlay";
Expand Down Expand Up @@ -615,10 +614,7 @@ internal partial class Strings
};

public string HighEndWarning { get; set; } = "Please separately keybind damage reduction / shield cooldowns in case RS fails at a crucial moment in {0}!";
public string HighEndBan { get; set; } = "{0} can not be used in High-end Duty!";
public string TextToTalkWarning { get; set; } = "You didn't install TextToTalk, please install it to make Rotation Solver say something for you!";

public string WhiteListDownloadingFailed { get; set; } = "Failed to load white List. Click to retry.";

public string ClickingMistakeMessage { get; set; } = "OOOps! RS clicked the wrong action ({0})!";
}
14 changes: 0 additions & 14 deletions RotationSolver/RotationSolverPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public sealed class RotationSolverPlugin : IDalamudPlugin, IDisposable
public string Name => "Rotation Solver";

public static DalamudLinkPayload OpenLinkPayload { get; private set; }
public static DalamudLinkPayload DownloadLinkPayload { get; private set; }
public RotationSolverPlugin(DalamudPluginInterface pluginInterface)
{
ECommonsMain.Init(pluginInterface, this, Module.DalamudReflector, Module.ObjectFunctions);
Expand Down Expand Up @@ -76,22 +75,9 @@ public RotationSolverPlugin(DalamudPluginInterface pluginInterface)
#endif
ChangeUITranslation();

OpenLinkPayload = pluginInterface.AddChatLinkHandler(0, (id, str) =>
{
if (id == 0) OpenConfigWindow();
});
DownloadLinkPayload = pluginInterface.AddChatLinkHandler(1, (id, str) =>
{
if (id == 1) Task.Run(async () =>
{
await RotationHelper.LoadListAsync();
});
});

Task.Run(async () =>
{
await RotationUpdater.GetAllCustomRotationsAsync(DownloadOption.Download);
await RotationHelper.LoadListAsync();
});
}

Expand Down
8 changes: 0 additions & 8 deletions RotationSolver/UI/ImGuiHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -535,14 +535,6 @@ public unsafe static void Display(this ICustomRotation rotation, ICustomRotation
HoveredString(string.Format(LocalizationManager.RightLang.ConfigWindow_Rotation_InvalidRotation,
rotation.GetType().Assembly.GetInfo().Author));
}
else if (!rotation.IsAllowed(out _))
{
var showStr = string.Format(LocalizationManager.RightLang.ConfigWindow_Helper_HighEndWarning, rotation)
+ string.Join("", SocialUpdater.HighEndDuties.Select(SocialUpdater.GetDutyName)
.Where(s => !string.IsNullOrEmpty(s)).Select(t => "\n - " + t));
HoveredString(showStr);
}
else if (rotation.IsBeta())
{
HoveredString(LocalizationManager.RightLang.ConfigWindow_Rotation_BetaRotation);
Expand Down
4 changes: 0 additions & 4 deletions RotationSolver/UI/RotationConfigWindow_Rotation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,6 @@ private static void DrawInfos()
ImGui.TableNextRow();

var assembly = grp.Key;
var isAllowed = assembly.IsAllowed();
if (!isAllowed) ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudViolet);

var info = assembly.GetInfo();
ImGui.TableNextColumn();
Expand Down Expand Up @@ -402,8 +400,6 @@ private static void DrawInfos()
}
}
ImGui.PopStyleColor(3);

if (!isAllowed) ImGui.PopStyleColor();
}
ImGui.EndTable();
}
Expand Down
3 changes: 1 addition & 2 deletions RotationSolver/Updaters/ActionSequencerUpdater.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using FFXIVClientStructs.FFXIV.Client.Game.InstanceContent;
using RotationSolver.ActionSequencer;
using RotationSolver.ActionSequencer;
using RotationSolver.UI;
using System.Diagnostics;

Expand Down
1 change: 0 additions & 1 deletion RotationSolver/Updaters/RotationUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,6 @@ internal static ICustomRotation GetChosenRotation(CustomRotationGroup group)
var has = Service.Config.RotationChoices.TryGetValue((uint)group.JobId, out var name);

var rotation = group.Rotations.FirstOrDefault(r => r.GetType().FullName == name);
rotation ??= group.Rotations.FirstOrDefault(r => r.IsAllowed(out _));
rotation ??= group.Rotations.FirstOrDefault();

if (!has && rotation != null)
Expand Down

0 comments on commit 3a7bdd6

Please sign in to comment.