Skip to content

Commit 59db132

Browse files
authored
Upgrade API 11 (#6)
1 parent f906904 commit 59db132

File tree

12 files changed

+42
-52
lines changed

12 files changed

+42
-52
lines changed

WoLua/ExcelContainer.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
11
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Reflection;
5-
using System.Runtime.CompilerServices;
6-
using System.Text;
72
using System.Threading;
8-
using System.Threading.Tasks;
93

104
using Lumina.Excel;
11-
using Lumina.Excel.GeneratedSheets;
5+
using Lumina.Excel.Sheets;
126

137
namespace PrincessRTFM.WoLua;
148

159
public static class ExcelContainer {
16-
private static Lazy<ExcelSheet<T>> init<T>() where T: ExcelRow {
10+
private static Lazy<ExcelSheet<T>> init<T>() where T: struct, IExcelRow<T> {
1711
return new(() => {
1812
if (Service.DataManager is null)
1913
throw new InvalidOperationException("Cannot load excel sheet without DataManager instance", new NullReferenceException("Service.DataManager does not exist"));

WoLua/Game/ServerChat.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ namespace PrincessRTFM.WoLua.Game;
1313

1414
internal class ServerChat {
1515
private static class Signatures {
16-
internal const string SendChat = "48 89 5C 24 ?? 57 48 83 EC 20 48 8B FA 48 8B D9 45 84 C9";
17-
internal const string SanitiseString = "E8 ?? ?? ?? ?? 48 8D 4C 24 ?? 0F B6 F0 E8 ?? ?? ?? ?? 48 8D 4D C0";
16+
internal const string SendChat = "48 89 5C 24 ?? 48 89 74 24 ?? 57 48 83 EC 20 48 8B F2 48 8B F9 45 84 C9";
17+
internal const string SanitiseString = "E8 ?? ?? ?? ?? EB 0A 48 8D 4C 24 ?? E8 ?? ?? ?? ?? 48 8D AE";
1818
}
1919

2020

WoLua/Lua/Api/Game/EntityWrapper.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
using FFXIVClientStructs.FFXIV.Client.Game.Character;
99

10-
using Lumina.Excel.GeneratedSheets;
10+
using Lumina.Excel.Sheets;
1111

1212
using MoonSharp.Interpreter;
1313

@@ -86,9 +86,9 @@ public string? TitleText {
8686
if (!this.IsPlayer)
8787
return null;
8888
Title? title = this.playerTitle;
89-
return title is null
90-
? string.Empty
91-
: this.MF(title.Masculine, title.Feminine);
89+
return title.HasValue
90+
? this.MF(title.Value.Masculine.ToString(), title.Value.Feminine.ToString())
91+
: string.Empty;
9292
}
9393
}
9494
public bool? TitleIsPrefix => this.IsPlayer ? this.playerTitle?.IsPrefix : null;
@@ -113,11 +113,11 @@ public string? TitleText {
113113

114114
#region Worlds
115115

116-
public ushort? HomeWorldId => this.IsPlayer && this.Entity is IPlayerCharacter p ? (ushort)p.HomeWorld.GameData!.RowId : null;
117-
public string? HomeWorld => this.IsPlayer && this.Entity is IPlayerCharacter p ? p.HomeWorld.GameData!.Name!.RawString : null;
116+
public ushort? HomeWorldId => this.IsPlayer && this.Entity is IPlayerCharacter p ? (ushort)p.HomeWorld.Value.RowId : null;
117+
public string? HomeWorld => this.IsPlayer && this.Entity is IPlayerCharacter p ? p.HomeWorld.Value.Name!.ToString() : null;
118118

119-
public ushort? CurrentWorldId => this.IsPlayer && this.Entity is IPlayerCharacter p ? (ushort)p.CurrentWorld.GameData!.RowId : null;
120-
public string? CurrentWorld => this.IsPlayer && this.Entity is IPlayerCharacter p ? p.CurrentWorld.GameData!.Name!.RawString : null;
119+
public ushort? CurrentWorldId => this.IsPlayer && this.Entity is IPlayerCharacter p ? (ushort)p.CurrentWorld.Value.RowId : null;
120+
public string? CurrentWorld => this.IsPlayer && this.Entity is IPlayerCharacter p ? p.CurrentWorld.Value.Name!.ToString() : null;
121121

122122
#endregion
123123

@@ -149,7 +149,7 @@ public string? TitleText {
149149
public JobData Job {
150150
get {
151151
return this && this.Entity is ICharacter self
152-
? new(self.ClassJob!.Id, self.ClassJob!.GameData!.Name!.ToString().ToLower(), self.ClassJob!.GameData!.Abbreviation!.ToString().ToUpper())
152+
? new(self.ClassJob.RowId, self.ClassJob!.Value.Name!.ToString().ToLower(), self.ClassJob!.Value.Abbreviation!.ToString().ToUpper())
153153
: new(0, JobData.InvalidJobName, JobData.InvalidJobAbbr);
154154
}
155155
}

WoLua/Lua/Api/Game/FateWrapper.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22

33
using Dalamud.Game.ClientState.Fates;
44

5-
using FFXIVClientStructs.FFXIV.Client.Game.Fate;
6-
75
using MoonSharp.Interpreter;
86

97
using PrincessRTFM.WoLua.Constants;
108
using PrincessRTFM.WoLua.Lua.Docs;
119

1210
using Fate = Dalamud.Game.ClientState.Fates.IFate;
11+
using FateContext = FFXIVClientStructs.FFXIV.Client.Game.Fate.FateContext;
1312

1413
namespace PrincessRTFM.WoLua.Lua.Api.Game;
1514

WoLua/Lua/Api/Game/MountWrapper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using System.Collections.Generic;
33

44
using Lumina.Excel;
5-
using Lumina.Excel.GeneratedSheets;
5+
using Lumina.Excel.Sheets;
66

77
using MoonSharp.Interpreter;
88

@@ -21,7 +21,7 @@ internal static void LoadGameData() {
2121

2222
ExcelSheet<Mount> mounts = Service.DataManager.GetExcelSheet<Mount>()!;
2323
foreach (Mount mount in mounts) {
24-
mountNames[(ushort)mount.RowId] = mount.Singular;
24+
mountNames[(ushort)mount.RowId] = mount.Singular.ToString();
2525
mountArticles[(ushort)mount.RowId] = "A" + (mount.StartsWithVowel > 0 ? "n" : string.Empty);
2626
}
2727
mountNames.Remove(0);

WoLua/Lua/Api/Game/PlayerApi.cs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
1111

1212
using Lumina.Excel;
13-
using Lumina.Excel.GeneratedSheets;
13+
using Lumina.Excel.Sheets;
1414

1515
using MoonSharp.Interpreter;
1616

@@ -252,7 +252,6 @@ internal PlayerApi(ScriptContainer source) : base(source) { }
252252
[LuaDoc("Provides three values consisting of the current character's X (east/west), Y (north/south), and Z (vertical) coordinates.",
253253
"If the player isn't loaded, all three values will be nil.",
254254
"This property is shorthand for `.Entity.MapCoords`.")]
255-
[return: AsLuaType(LuaType.Number)]
256255
public DynValue MapCoords => this.Entity.MapCoords;
257256

258257
[LuaPlayerDoc("The current character's rotation in radians, ranging from 0 to 2pi.",
@@ -476,24 +475,24 @@ internal static void InitialiseEmotes() {
476475

477476
ExcelSheet<Emote> emotes = Service.DataManager.GameData.GetExcelSheet<Emote>()!;
478477
try {
479-
uint max = emotes.RowCount;
478+
int max = emotes.Count;
480479
Service.Log.Information($"[{LogTag.Emotes}] Indexing {max:N0} emotes...");
481480
for (uint i = 0; i < max; ++i) {
482-
Emote? emote = emotes.GetRow(i);
483-
if (emote is not null) {
481+
Emote? emote = emotes.GetRowOrDefault(i);
482+
if (emote.HasValue) {
484483
string[] commands = (new string?[] {
485-
emote.Name.RawString,
486-
emote.TextCommand.Value?.Command?.ToString(),
487-
emote.TextCommand.Value?.ShortCommand?.ToString(),
488-
emote.TextCommand.Value?.Alias?.ToString(),
489-
emote.TextCommand.Value?.ShortAlias?.ToString(),
484+
emote.Value.Name.ToString(),
485+
emote.Value.TextCommand.ValueNullable?.Command.ToString(),
486+
emote.Value.TextCommand.ValueNullable?.ShortCommand.ToString(),
487+
emote.Value.TextCommand.ValueNullable?.Alias.ToString(),
488+
emote.Value.TextCommand.ValueNullable?.ShortAlias.ToString(),
490489
})
491490
.Where(s => !string.IsNullOrWhiteSpace(s))
492491
.Cast<string>()
493492
.Select(s => s.TrimStart('/'))
494493
.ToArray();
495494
foreach (string command in commands)
496-
emoteUnlocks[command] = emote.UnlockLink;
495+
emoteUnlocks[command] = emote.Value.UnlockLink;
497496
}
498497
}
499498
Service.Log.Information($"[{LogTag.Emotes}] Cached {emoteUnlocks.Count:N0} emote names");

WoLua/Lua/Api/Game/WeatherWrapper.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using System.Collections.Generic;
33

44
using Lumina.Excel;
5-
using Lumina.Excel.GeneratedSheets;
5+
using Lumina.Excel.Sheets;
66

77
using MoonSharp.Interpreter;
88

@@ -56,8 +56,8 @@ internal static void LoadGameData() {
5656
if (Service.DataManager.GetExcelSheet<Weather>() is ExcelSheet<Weather> skies) {
5757
// Cache the names and descriptions for each type of weather
5858
foreach (Weather row in skies) {
59-
weatherNames[row.RowId] = row.Name;
60-
weatherDescriptions[row.RowId] = row.Description;
59+
weatherNames[row.RowId] = row.Name.ToString();
60+
weatherDescriptions[row.RowId] = row.Description.ToString();
6161
}
6262
Service.Log.Information($"[{LogTag.Weather}] Indexed {weatherNames.Count} weather types");
6363
}

WoLua/Lua/Api/Game/WorldPosition.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using Dalamud.Game.ClientState.Objects.Types;
55
using Dalamud.Utility;
66

7-
using Lumina.Excel.GeneratedSheets;
7+
using Lumina.Excel.Sheets;
88

99
using MoonSharp.Interpreter;
1010

@@ -46,10 +46,10 @@ internal Vector3? UiCoords {
4646
return null;
4747
uint zone = Service.ClientState.TerritoryType;
4848
if (zone > 0) {
49-
Map? map = Service.DataManager.GetExcelSheet<Map>()!.GetRow(zone);
50-
TerritoryTypeTransient? territoryTransient = Service.DataManager.GetExcelSheet<TerritoryTypeTransient>()!.GetRow(zone);
51-
if (map is not null && territoryTransient is not null) {
52-
return MapUtil.WorldToMap(this.GameEnginePosition, map, territoryTransient, true);
49+
Map? map = Service.DataManager.GetExcelSheet<Map>()!.GetRowOrDefault(zone);
50+
TerritoryTypeTransient? territoryTransient = Service.DataManager.GetExcelSheet<TerritoryTypeTransient>()!.GetRowOrDefault(zone);
51+
if (map.HasValue && territoryTransient.HasValue) {
52+
return MapUtil.WorldToMap(this.GameEnginePosition, map.Value, territoryTransient.Value, true);
5353
}
5454
}
5555
return null;

WoLua/Plugin.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
using FFXIVClientStructs.FFXIV.Client.Game.Character;
1414
using FFXIVClientStructs.FFXIV.Client.Graphics.Environment;
1515

16-
using Lumina.Excel.GeneratedSheets;
16+
using Lumina.Excel.Sheets;
1717

1818
using MoonSharp.Interpreter;
1919
using MoonSharp.Interpreter.Platforms;
@@ -24,8 +24,6 @@
2424
using PrincessRTFM.WoLua.Ui;
2525
using PrincessRTFM.WoLua.Ui.Chat;
2626

27-
using XivCommon;
28-
2927
namespace PrincessRTFM.WoLua;
3028

3129
public class Plugin: IDalamudPlugin {
@@ -218,7 +216,7 @@ public void OnCommand(string command, string argline) {
218216
break;
219217
case "class":
220218
case "job":
221-
if (Service.ClientState.LocalPlayer.ClassJob.GameData is ClassJob job) {
219+
if (Service.ClientState.LocalPlayer.ClassJob.Value is ClassJob job) {
222220
this.Print($"You current job is {job.RowId} ({job.Abbreviation}, {job.Name}) at level {Service.ClientState.LocalPlayer.Level}.");
223221
}
224222
else {

WoLua/dalamud.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<Import Project="framework.props" />
1616

1717
<ItemGroup>
18-
<PackageReference Include="DalamudPackager" Version="2.1.13" />
18+
<PackageReference Include="DalamudPackager" Version="11.0.0" />
1919
<Reference Include="Newtonsoft.Json">
2020
<HintPath>$(DalamudLibPath)Newtonsoft.Json.dll</HintPath>
2121
<Private>False</Private>

0 commit comments

Comments
 (0)