Skip to content

Commit

Permalink
Merge pull request #691 from Diyagi/api11
Browse files Browse the repository at this point in the history
Update to API 11 and Lumina 5
  • Loading branch information
SlashNephy authored Nov 21, 2024
2 parents 4f14499 + 6eb5d76 commit 37ca918
Show file tree
Hide file tree
Showing 30 changed files with 212 additions and 166 deletions.
18 changes: 9 additions & 9 deletions AetheryteLinkInChat/AetheryteLinkInChat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ private void AppendNearestAetheryteLink(ref SeString message)
solver.AppendGrandCompanyAetheryte(paths,
(uint)Enum.GetValues<GrandCompanyAetheryte>()[Config.PreferredGrandCompanyAetheryte],
message,
Dalamud.ClientState.LocalPlayer?.CurrentWorld.GameData,
Dalamud.ClientState.LocalPlayer?.CurrentWorld.Value,
Dalamud.ClientState.TerritoryType);
}

Expand All @@ -109,7 +109,7 @@ private void AppendNearestAetheryteLink(ref SeString message)
new UIForegroundPayload(069),
..SeString.TextArrowPayloads,
aetheryteLinkPayload,
new TextPayload(aetheryte.Aetheryte.PlaceName.Value?.Name.RawString),
new TextPayload(aetheryte.Aetheryte.PlaceName.Value.Name.ExtractText()),
new AetherytePayload(aetheryte.Aetheryte).ToRawPayload(),
RawPayload.LinkTerminator,
UIForegroundPayload.UIForegroundOff,
Expand All @@ -119,14 +119,14 @@ private void AppendNearestAetheryteLink(ref SeString message)
case AetheryteTeleportPath { Aetheryte.IsAetheryte: false } aetheryte:
payloads.AddRange([
new IconPayload(BitmapFontIcon.Aethernet),
new TextPayload(aetheryte.Aetheryte.AethernetName.Value?.Name.RawString),
new TextPayload(aetheryte.Aetheryte.AethernetName.Value.Name.ExtractText()),
]);
break;
// マップ境界
case BoundaryTeleportPath boundary:
payloads.AddRange([
new IconPayload(BitmapFontIcon.FlyZone),
new TextPayload(boundary.ConnectedMarker.PlaceNameSubtext.Value?.Name.RawString),
new TextPayload(boundary.ConnectedMarker.PlaceNameSubtext.Value.Name.ExtractText()),
]);
break;
// ワールド間テレポ
Expand All @@ -135,13 +135,13 @@ private void AppendNearestAetheryteLink(ref SeString message)
new IconPayload(BitmapFontIcon.Aetheryte),
new UIForegroundPayload(069),
aetheryteLinkPayload,
new TextPayload(world.Aetheryte.PlaceName.Value?.Name.RawString),
new TextPayload(world.Aetheryte.PlaceName.Value.Name.ExtractText()),
new AetherytePayload(world.Aetheryte).ToRawPayload(),
RawPayload.LinkTerminator,
UIForegroundPayload.UIForegroundOff,
new TextPayload($" {SeIconChar.ArrowRight.ToIconString()} "),
new IconPayload(BitmapFontIcon.CrossWorld),
new TextPayload(world.World.Name.RawString),
new TextPayload(world.World.Name.ExtractText()),
]);
break;
}
Expand All @@ -154,7 +154,7 @@ private void AppendNearestAetheryteLink(ref SeString message)

if (Config.EnableLifestreamIntegration && teleporter.IsLifestreamAvailable())
{
var world = solver.DetectWorld(message, Dalamud.ClientState.LocalPlayer?.CurrentWorld.GameData);
var world = solver.DetectWorld(message, Dalamud.ClientState.LocalPlayer?.CurrentWorld.Value);

payloads.AddRange([
new TextPayload(" ["),
Expand Down Expand Up @@ -261,12 +261,12 @@ private void OnTeleportGcCommand(string command, string arguments)
}

var aetheryte = solver.GetAetheryteById(aetheryteId);
if (aetheryte == default)
if (!aetheryte.HasValue)
{
return;
}

teleporter.TeleportToAetheryte(aetheryte);
teleporter.TeleportToAetheryte(aetheryte.Value);
}

protected override void ReleaseManaged()
Expand Down
2 changes: 1 addition & 1 deletion AetheryteLinkInChat/AetheryteLinkInChat.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<Private>False</Private>
</Reference>

<PackageReference Include="DalamudPackager" Version="2.1.13">
<PackageReference Include="DalamudPackager" Version="11.0.0">
<PrivateAssets>all</PrivateAssets>
</PackageReference>

Expand Down
3 changes: 1 addition & 2 deletions AetheryteLinkInChat/AetheryteLinkInChat.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@
"Punchline": "Quick teleport for mob hunts and treasure hunts!",
"Description": "Display a teleport link to the nearest aetherite for the map link from the in-game chat. Type /alic to configure the plugin.",
"Tags": ["teleporter"],
"CategoryTags": ["utility"],
"DalamudApiLevel": 10
"CategoryTags": ["utility"]
}
22 changes: 17 additions & 5 deletions AetheryteLinkInChat/Config/PluginConfigWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.Numerics;
using Dalamud.Divination.Common.Api.Ui.Window;
using ImGuiNET;
using Lumina.Excel.GeneratedSheets;
using Lumina.Excel.Sheets;

namespace Divination.AetheryteLinkInChat.Config;

Expand All @@ -25,9 +25,11 @@ public PluginConfigWindow()
}

grandCompanyAetheryteNames = Enum.GetValues<GrandCompanyAetheryte>()
.Select(x => sheet?.GetRow((uint)x)?.PlaceName.Value?.Name.RawString ?? Enum.GetName(x) ?? string.Empty)
.Select(x => sheet.HasRow((uint)x) ?
sheet.GetRow((uint)x).PlaceName.Value.Name.ExtractText() :
Enum.GetName(x) ?? string.Empty)
.ToArray();
aetherytes = sheet.Where(x => x.IsAetheryte && !x.Invisible && x.RowId != 1).ToImmutableList();
aetherytes = sheet.Where(x => x is { IsAetheryte: true, Invisible: false } && x.RowId != 1).ToImmutableList();
}

public override void Draw()
Expand Down Expand Up @@ -128,8 +130,18 @@ private void DrawAetheryteListTab()
ImGui.Text(aetheryte.RowId.ToString());

ImGui.TableNextColumn();
var aetheryteName = aetheryte.PlaceName.Value?.Name.RawString ?? "???";
var zoneName = aetheryte.Map.Value?.PlaceName.Value?.Name.RawString ?? "???";
var aetheryteName = "???";
var zoneName = "???";

if (aetheryte.PlaceName.IsValid)
{
aetheryteName = aetheryte.PlaceName.Value.Name.ExtractText();
}

if (aetheryte.Map is { IsValid: true, Value.PlaceName.IsValid: true })
{
zoneName = aetheryte.Map.Value.PlaceName.Value.Name.ExtractText();
}

if (Config.IgnoredAetheryteIds.Contains(aetheryte.RowId))
{
Expand Down
6 changes: 3 additions & 3 deletions AetheryteLinkInChat/Ipc/IpcProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using Dalamud.Plugin.Services;
using Divination.AetheryteLinkInChat.IpcModel;
using Divination.AetheryteLinkInChat.Solver;
using Lumina.Excel.GeneratedSheets;
using Lumina.Excel.Sheets;

namespace Divination.AetheryteLinkInChat.Ipc;

Expand Down Expand Up @@ -36,10 +36,10 @@ private bool OnTeleport(TeleportPayload payload)
{
DalamudLog.Log.Debug("OnTeleport: {Payload}", payload);

var world = clientState.LocalPlayer?.CurrentWorld?.GameData;
var world = clientState.LocalPlayer?.CurrentWorld.Value;
if (payload.WorldId.HasValue)
{
world = dataManager.GetExcelSheet<World>()?.GetRow(payload.WorldId.Value);
world = dataManager.GetExcelSheet<World>().GetRow(payload.WorldId.Value);
}

var mapLink = new MapLinkPayload(payload.TerritoryTypeId, payload.MapId, payload.Coordinates.X, payload.Coordinates.Y);
Expand Down
12 changes: 8 additions & 4 deletions AetheryteLinkInChat/Payloads/AetherytePayload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.IO;
using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Game.Text.SeStringHandling.Payloads;
using Lumina.Excel.GeneratedSheets;
using Lumina.Excel.Sheets;

namespace Divination.AetheryteLinkInChat.Payloads;

Expand All @@ -12,7 +12,9 @@ public sealed class AetherytePayload : DalamudLinkPayload
internal const byte EmbeddedInfoTypeByte = (byte)(EmbeddedInfoType.DalamudLink + 1);

public uint AetheryteId { get; set; }
public Aetheryte Aetheryte => DataResolver.GetExcelSheet<Aetheryte>()?.GetRow(AetheryteId) ?? throw new InvalidOperationException("invalid aetheryte ID");
public Aetheryte Aetheryte => AetheryteLinkInChat.Instance.Dalamud.DataManager.GetExcelSheet<Aetheryte>().HasRow(AetheryteId)
? AetheryteLinkInChat.Instance.Dalamud.DataManager.GetExcelSheet<Aetheryte>().GetRow(AetheryteId)
: throw new InvalidOperationException("invalid aetheryte ID");

public override PayloadType Type => PayloadType.Unknown;

Expand All @@ -30,13 +32,15 @@ protected override byte[] EncodeImpl()
var data = MakeInteger(AetheryteId);
var length = 2 + (byte)data.Length;

return [
return
[
START_BYTE,
(byte)SeStringChunkType.Interactable,
(byte)length,
EmbeddedInfoTypeByte,
.. data,
END_BYTE];
END_BYTE
];
}

protected override void DecodeImpl(BinaryReader reader, long _)
Expand Down
2 changes: 1 addition & 1 deletion AetheryteLinkInChat/Payloads/LifestreamPayload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.IO;
using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Game.Text.SeStringHandling.Payloads;
using Lumina.Excel.GeneratedSheets;
using Lumina.Excel.Sheets;

namespace Divination.AetheryteLinkInChat.Payloads;

Expand Down
Loading

0 comments on commit 37ca918

Please sign in to comment.