Skip to content

Commit

Permalink
Update for API9
Browse files Browse the repository at this point in the history
  • Loading branch information
MidoriKami committed Oct 3, 2023
1 parent b6d830f commit 770dfcf
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 55 deletions.
12 changes: 6 additions & 6 deletions ZodiacBuddy/BonusLight/BonusLightManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public BonusLightManager()

Service.ClientState.Login += this.OnLogin;
Service.ClientState.Logout += this.OnLogout;
if (Service.ClientState.LocalPlayer is not null) this.OnLogin(null, null!);
if (Service.ClientState.LocalPlayer is not null) this.OnLogin();
this.resetTimer = new Timer(_ => this.ResetBonus(), null, delta, TimeSpan.FromHours(2));
}

Expand Down Expand Up @@ -178,14 +178,14 @@ private void RetrieveLastReport()
this.Send(request, this.OnLastReportResponse);
}

private void OnLogin(object? sender, EventArgs e)
private void OnLogin()
{
this.checkTimer?.Dispose();
this.checkTimer =
new Timer(_ => this.RetrieveLastReport(), null, TimeSpan.FromSeconds(2), TimeSpan.FromMinutes(5));
}

private void OnLogout(object? sender, EventArgs e)
private void OnLogout()
{
this.checkTimer?.Dispose();
this.ResetBonus();
Expand Down Expand Up @@ -237,16 +237,16 @@ private void Send(HttpRequestMessage request, Action<string>? successCallback)
this.LastRequestIsSuccess = response.IsSuccessStatusCode;
if (!response.IsSuccessStatusCode)
{
PluginLog.Warning($"{request.RequestUri} => [{response.StatusCode:D}] {content}");
Service.PluginLog.Warning($"{request.RequestUri} => [{response.StatusCode:D}] {content}");
return;
}
PluginLog.Verbose($"{request.RequestUri} => [{response.StatusCode:D}] {content}");
Service.PluginLog.Verbose($"{request.RequestUri} => [{response.StatusCode:D}] {content}");
successCallback?.Invoke(content);
}
catch (HttpRequestException e)
{
PluginLog.Error($"{request.RequestUri} => {e}");
Service.PluginLog.Error($"{request.RequestUri} => {e}");
this.LastRequestIsSuccess = false;
}
});
Expand Down
35 changes: 24 additions & 11 deletions ZodiacBuddy/Service.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Dalamud.Game.Gui.Toast;
using Dalamud.IoC;
using Dalamud.Plugin;
using Dalamud.Plugin.Services;
using ZodiacBuddy.BonusLight;

namespace ZodiacBuddy
Expand Down Expand Up @@ -44,66 +45,78 @@ internal class Service
/// Gets the Dalamud chat gui.
/// </summary>
[PluginService]
internal static ChatGui ChatGui { get; private set; } = null!;
internal static IChatGui ChatGui { get; private set; } = null!;

/// <summary>
/// Gets the Dalamud client state.
/// </summary>
[PluginService]
internal static ClientState ClientState { get; private set; } = null!;
internal static IClientState ClientState { get; private set; } = null!;

/// <summary>
/// Gets the Dalamud duty state.
/// </summary>
[PluginService]
internal static DutyState DutyState { get; private set; } = null!;
internal static IDutyState DutyState { get; private set; } = null!;

/// <summary>
/// Gets the Dalamud command manager.
/// </summary>
[PluginService]
internal static CommandManager CommandManager { get; private set; } = null!;
internal static ICommandManager CommandManager { get; private set; } = null!;

/// <summary>
/// Gets the Dalamud condition.
/// </summary>
[PluginService]
internal static Condition Condition { get; private set; } = null!;
internal static ICondition Condition { get; private set; } = null!;

/// <summary>
/// Gets the Dalamud data manager.
/// </summary>
[PluginService]
internal static DataManager DataManager { get; private set; } = null!;
internal static IDataManager DataManager { get; private set; } = null!;

/// <summary>
/// Gets the Dalamud framework manager.
/// </summary>
[PluginService]
internal static Framework Framework { get; private set; } = null!;
internal static IFramework Framework { get; private set; } = null!;

/// <summary>
/// Gets the Dalamud game gui.
/// </summary>
[PluginService]
internal static GameGui GameGui { get; private set; } = null!;
internal static IGameGui GameGui { get; private set; } = null!;

/// <summary>
/// Gets the Dalamud job gauges.
/// </summary>
[PluginService]
internal static JobGauges JobGauges { get; private set; } = null!;
internal static IJobGauges JobGauges { get; private set; } = null!;

/// <summary>
/// Gets the Dalamud target manager.
/// </summary>
[PluginService]
internal static TargetManager TargetManager { get; private set; } = null!;
internal static ITargetManager TargetManager { get; private set; } = null!;

/// <summary>
/// Gets the Dalamud toast manager.
/// </summary>
[PluginService]
internal static ToastGui Toasts { get; private set; } = null!;
internal static IToastGui Toasts { get; private set; } = null!;

/// <summary>
/// Gets the Dalamud Hooker.
/// </summary>
[PluginService]
internal static IGameInteropProvider Hooker { get; private set; } = null!;

/// <summary>
/// Gets the Plugin Log.
/// </summary>
[PluginService]
internal static IPluginLog PluginLog { get; private set; } = null!;
}
}
14 changes: 7 additions & 7 deletions ZodiacBuddy/Stages/Atma/AtmaManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ internal partial class AtmaManager : IDisposable
/// </summary>
public AtmaManager()
{
SignatureHelper.Initialise(this);
Service.Hooker.InitializeFromAttributes(this);
this.receiveEventHook.Enable();
}

Expand Down Expand Up @@ -79,15 +79,15 @@ static float ConvertRawPositionToMapCoordinate(int pos, float scale)
var mapMarker = mapMarkers.FirstOrDefault(m => m.DataType == 3 && m.DataKey == aetheryte.RowId);
if (mapMarker == default)
{
// PluginLog.Debug($"Could not find aetheryte: {name}");
// Service.PluginLog.Debug($"Could not find aetheryte: {name}");
return 0;
}

var aetherX = ConvertRawPositionToMapCoordinate(mapMarker.X, scale);
var aetherY = ConvertRawPositionToMapCoordinate(mapMarker.Y, scale);

// var aetheryteName = aetheryte.PlaceName.Value!;
// PluginLog.Debug($"Aetheryte found: {aetherName} ({aetherX} ,{aetherY})");
// Service.PluginLog.Debug($"Aetheryte found: {aetherName} ({aetherX} ,{aetherY})");
var distance = Math.Pow(aetherX - mapLink.XCoord, 2) + Math.Pow(aetherY - mapLink.YCoord, 2);
if (distance < closestDistance)
{
Expand All @@ -108,7 +108,7 @@ private unsafe bool Teleport(uint aetheryteID)
if (telepo == null)
{
Service.Plugin.PrintError("Something horrible happened, please contact the developer.");
PluginLog.Error("Could not teleport: Telepo is missing.");
Service.PluginLog.Error("Could not teleport: Telepo is missing.");
return false;
}

Expand Down Expand Up @@ -147,7 +147,7 @@ private unsafe void ReceiveEventDetour(IntPtr addon, uint which, IntPtr eventDat
}
catch (Exception ex)
{
PluginLog.Error(ex, "Exception during hook: AddonRelicNotebook.ReceiveEvent:Click");
Service.PluginLog.Error(ex, "Exception during hook: AddonRelicNotebook.ReceiveEvent:Click");
}
}

Expand Down Expand Up @@ -200,7 +200,7 @@ unsafe static bool IsOwnerNode(IntPtr target, AtkComponentCheckBox* checkbox)
? $"{selectedTarget.LocationName}, {selectedTarget.ZoneName}"
: selectedTarget.ZoneName;

// PluginLog.Debug($"Target selected: {selectedTarget.Name} in {zoneName}.");
// Service.PluginLog.Debug($"Target selected: {selectedTarget.Name} in {zoneName}.");
if (Service.Configuration.BraveEchoTarget)
{
var sb = new SeStringBuilder()
Expand All @@ -227,7 +227,7 @@ unsafe static bool IsOwnerNode(IntPtr target, AtkComponentCheckBox* checkbox)
}
else
{
PluginLog.Warning($"Could not find an aetheryte for {zoneName}");
Service.PluginLog.Warning($"Could not find an aetheryte for {zoneName}");
}
}
else
Expand Down
12 changes: 6 additions & 6 deletions ZodiacBuddy/Stages/Atma/Data/BraveBook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private static void PopulateDataset()
var fateCount = bookRow.Fate.Length;
var leveCount = bookRow.Leve.Length;

// PluginLog.Debug($"Loading book {bookID}: {bookName}");
// Service.PluginLog.Debug($"Loading book {bookID}: {bookName}");
var braveBook = Dataset[bookRow.RowId] = new BraveBook()
{
Name = bookName,
Expand All @@ -100,7 +100,7 @@ private static void PopulateDataset()

var position = GetMonsterPosition(mntc.RowId);

// PluginLog.Debug($"Loaded enemy {mntcID}: {name}");
// Service.PluginLog.Debug($"Loaded enemy {mntcID}: {name}");
braveBook.Enemies[i] = new BraveTarget()
{
Name = name,
Expand Down Expand Up @@ -128,7 +128,7 @@ private static void PopulateDataset()

var cfcID = position.TerritoryType.ContentFinderCondition.Value!.RowId;

// PluginLog.Debug($"Loaded dungeon {mntcID}: {name}");
// Service.PluginLog.Debug($"Loaded dungeon {mntcID}: {name}");
braveBook.Dungeons[i] = new BraveTarget()
{
Name = name,
Expand All @@ -152,7 +152,7 @@ private static void PopulateDataset()

var name = fate.Name;

// PluginLog.Debug($"Loaded fate {fateID}: {name}");
// Service.PluginLog.Debug($"Loaded fate {fateID}: {name}");
braveBook.Fates[i] = new BraveTarget()
{
Name = name,
Expand All @@ -176,7 +176,7 @@ private static void PopulateDataset()
var zoneName = position.TerritoryType.PlaceName.Value!.Name.ToString();
var zoneID = position.TerritoryType.RowId;

// PluginLog.Debug($"Loaded leve {leveID}: {name}");
// Service.PluginLog.Debug($"Loaded leve {leveID}: {name}");
braveBook.Leves[i] = new BraveTarget()
{
Name = leveName,
Expand All @@ -191,7 +191,7 @@ private static void PopulateDataset()
}
catch (Exception ex)
{
PluginLog.Error(ex, "An error occurred during plugin data load.");
Service.PluginLog.Error(ex, "An error occurred during plugin data load.");
throw;
}
}
Expand Down
9 changes: 5 additions & 4 deletions ZodiacBuddy/Stages/Brave/BraveManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Dalamud.Game;
using Dalamud.Hooking;
using Dalamud.Logging;
using Dalamud.Plugin.Services;
using Dalamud.Utility.Signatures;
using FFXIVClientStructs.FFXIV.Component.GUI;
using ZodiacBuddy.BonusLight;
Expand Down Expand Up @@ -40,7 +41,7 @@ public BraveManager()
Service.Framework.Update += this.OnUpdate;
Service.Interface.UiBuilder.Draw += this.window.Draw;

SignatureHelper.Initialise(this);
Service.Hooker.InitializeFromAttributes(this);
this.addonRelicMagiciteOnSetupHook?.Enable();
}

Expand Down Expand Up @@ -68,7 +69,7 @@ private void AddonRelicMagiciteOnSetupDetour(IntPtr addonRelicMagicite, uint a2,
}
catch (Exception ex)
{
PluginLog.Error(ex, $"Unhandled error during {nameof(BraveManager)}.{nameof(this.AddonRelicMagiciteOnSetupDetour)}");
Service.PluginLog.Error(ex, $"Unhandled error during {nameof(BraveManager)}.{nameof(this.AddonRelicMagiciteOnSetupDetour)}");
}
}

Expand Down Expand Up @@ -114,15 +115,15 @@ private unsafe void UpdateRelicMagiciteAddon(int slot)
analyzeText->SetText(lightText->NodeText.ToString());
}

private void OnUpdate(Framework framework)
private void OnUpdate(IFramework framework)
{
try
{
this.OnUpdateInner();
}
catch (Exception ex)
{
PluginLog.Error(ex, $"Unhandled error during {nameof(BraveManager)}.{nameof(this.OnUpdate)}");
Service.PluginLog.Error(ex, $"Unhandled error during {nameof(BraveManager)}.{nameof(this.OnUpdate)}");
}
}

Expand Down
16 changes: 8 additions & 8 deletions ZodiacBuddy/Stages/Novus/NovusManager.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System;
using Dalamud.Game;

using Dalamud.Game.Gui.Toast;
using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Hooking;
using Dalamud.Logging;
using Dalamud.Plugin.Services;
using Dalamud.Utility.Signatures;
using FFXIVClientStructs.FFXIV.Component.GUI;
using ZodiacBuddy.BonusLight;
Expand Down Expand Up @@ -47,7 +47,7 @@ public NovusManager()
Service.ClientState.TerritoryChanged += this.OnTerritoryChange;
Service.DutyState.DutyStarted += this.OnDutyStart;

SignatureHelper.Initialise(this);
Service.Hooker.InitializeFromAttributes(this);
this.addonRelicGlassOnSetupHook?.Enable();
}

Expand Down Expand Up @@ -78,7 +78,7 @@ private void AddonRelicGlassOnSetupDetour(IntPtr addonRelicGlass, uint a2, IntPt
}
catch (Exception ex)
{
PluginLog.Error(ex, $"Unhandled error during {nameof(NovusManager)}.{nameof(this.AddonRelicGlassOnSetupDetour)}");
Service.PluginLog.Error(ex, $"Unhandled error during {nameof(NovusManager)}.{nameof(this.AddonRelicGlassOnSetupDetour)}");
}
}

Expand Down Expand Up @@ -116,15 +116,15 @@ private unsafe void UpdateRelicGlassAddon(int slot, uint nodeID)
analyzeText->SetText(lightText->NodeText.ToString());
}

private void OnUpdate(Framework framework)
private void OnUpdate(IFramework framework)
{
try
{
this.OnUpdateInner();
}
catch (Exception ex)
{
PluginLog.Error(ex, $"Unhandled error during {nameof(NovusManager)}.{nameof(this.OnUpdate)}");
Service.PluginLog.Error(ex, $"Unhandled error during {nameof(NovusManager)}.{nameof(this.OnUpdate)}");
}
}

Expand Down Expand Up @@ -156,7 +156,7 @@ private void OnToast(ref SeString message, ref QuestToastOptions options, ref bo
}
catch (Exception ex)
{
PluginLog.Error(ex, $"Unhandled error during {nameof(NovusManager)}.{nameof(this.OnToast)}");
Service.PluginLog.Error(ex, $"Unhandled error during {nameof(NovusManager)}.{nameof(this.OnToast)}");
}
}

Expand Down Expand Up @@ -190,7 +190,7 @@ private void OnToastInner(ref SeString message, ref QuestToastOptions options, r
}
}

private void OnTerritoryChange(object? sender, ushort territoryId)
private void OnTerritoryChange(ushort territoryId)
{
// Reset territory info
this.dutyBeginning = null;
Expand Down
6 changes: 2 additions & 4 deletions ZodiacBuddy/ZodiacBuddy.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
<PropertyGroup>
<Authors>daemitus</Authors>
<Company>-</Company>
<Version>0.1.0.4</Version>
<Version>0.2.0.0</Version>
<Description>Complete your Zodiac relic with style.</Description>
<Copyright></Copyright>
<PackageProjectUrl>https://github.com/daemitus/ZodiacBuddy</PackageProjectUrl>
</PropertyGroup>

Expand All @@ -24,7 +23,6 @@
</PropertyGroup>

<PropertyGroup Label="Documentation">
<DocumentationFile></DocumentationFile>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

Expand All @@ -48,7 +46,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="DalamudPackager" Version="2.1.10" />
<PackageReference Include="DalamudPackager" Version="2.1.12" />
<PackageReference Include="LitJWT" Version="2.0.2" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.435">
<PrivateAssets>all</PrivateAssets>
Expand Down
Loading

0 comments on commit 770dfcf

Please sign in to comment.