diff --git a/WoLua/ExcelContainer.cs b/WoLua/ExcelContainer.cs index a4f2e19..a83ff7f 100644 --- a/WoLua/ExcelContainer.cs +++ b/WoLua/ExcelContainer.cs @@ -1,19 +1,13 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Text; using System.Threading; -using System.Threading.Tasks; using Lumina.Excel; -using Lumina.Excel.GeneratedSheets; +using Lumina.Excel.Sheets; namespace PrincessRTFM.WoLua; public static class ExcelContainer { - private static Lazy> init() where T: ExcelRow { + private static Lazy> init() where T: struct, IExcelRow { return new(() => { if (Service.DataManager is null) throw new InvalidOperationException("Cannot load excel sheet without DataManager instance", new NullReferenceException("Service.DataManager does not exist")); diff --git a/WoLua/Game/ServerChat.cs b/WoLua/Game/ServerChat.cs index 31d51fe..7b6c2e1 100644 --- a/WoLua/Game/ServerChat.cs +++ b/WoLua/Game/ServerChat.cs @@ -13,8 +13,8 @@ namespace PrincessRTFM.WoLua.Game; internal class ServerChat { private static class Signatures { - internal const string SendChat = "48 89 5C 24 ?? 57 48 83 EC 20 48 8B FA 48 8B D9 45 84 C9"; - internal const string SanitiseString = "E8 ?? ?? ?? ?? 48 8D 4C 24 ?? 0F B6 F0 E8 ?? ?? ?? ?? 48 8D 4D C0"; + 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"; + internal const string SanitiseString = "E8 ?? ?? ?? ?? EB 0A 48 8D 4C 24 ?? E8 ?? ?? ?? ?? 48 8D AE"; } diff --git a/WoLua/Lua/Api/Game/EntityWrapper.cs b/WoLua/Lua/Api/Game/EntityWrapper.cs index e2a100f..1c8edc7 100644 --- a/WoLua/Lua/Api/Game/EntityWrapper.cs +++ b/WoLua/Lua/Api/Game/EntityWrapper.cs @@ -7,7 +7,7 @@ using FFXIVClientStructs.FFXIV.Client.Game.Character; -using Lumina.Excel.GeneratedSheets; +using Lumina.Excel.Sheets; using MoonSharp.Interpreter; @@ -86,9 +86,9 @@ public string? TitleText { if (!this.IsPlayer) return null; Title? title = this.playerTitle; - return title is null - ? string.Empty - : this.MF(title.Masculine, title.Feminine); + return title.HasValue + ? this.MF(title.Value.Masculine.ToString(), title.Value.Feminine.ToString()) + : string.Empty; } } public bool? TitleIsPrefix => this.IsPlayer ? this.playerTitle?.IsPrefix : null; @@ -113,11 +113,11 @@ public string? TitleText { #region Worlds - public ushort? HomeWorldId => this.IsPlayer && this.Entity is IPlayerCharacter p ? (ushort)p.HomeWorld.GameData!.RowId : null; - public string? HomeWorld => this.IsPlayer && this.Entity is IPlayerCharacter p ? p.HomeWorld.GameData!.Name!.RawString : null; + public ushort? HomeWorldId => this.IsPlayer && this.Entity is IPlayerCharacter p ? (ushort)p.HomeWorld.Value.RowId : null; + public string? HomeWorld => this.IsPlayer && this.Entity is IPlayerCharacter p ? p.HomeWorld.Value.Name!.ToString() : null; - public ushort? CurrentWorldId => this.IsPlayer && this.Entity is IPlayerCharacter p ? (ushort)p.CurrentWorld.GameData!.RowId : null; - public string? CurrentWorld => this.IsPlayer && this.Entity is IPlayerCharacter p ? p.CurrentWorld.GameData!.Name!.RawString : null; + public ushort? CurrentWorldId => this.IsPlayer && this.Entity is IPlayerCharacter p ? (ushort)p.CurrentWorld.Value.RowId : null; + public string? CurrentWorld => this.IsPlayer && this.Entity is IPlayerCharacter p ? p.CurrentWorld.Value.Name!.ToString() : null; #endregion @@ -149,7 +149,7 @@ public string? TitleText { public JobData Job { get { return this && this.Entity is ICharacter self - ? new(self.ClassJob!.Id, self.ClassJob!.GameData!.Name!.ToString().ToLower(), self.ClassJob!.GameData!.Abbreviation!.ToString().ToUpper()) + ? new(self.ClassJob.RowId, self.ClassJob!.Value.Name!.ToString().ToLower(), self.ClassJob!.Value.Abbreviation!.ToString().ToUpper()) : new(0, JobData.InvalidJobName, JobData.InvalidJobAbbr); } } diff --git a/WoLua/Lua/Api/Game/FateWrapper.cs b/WoLua/Lua/Api/Game/FateWrapper.cs index 6650710..7d8e74c 100644 --- a/WoLua/Lua/Api/Game/FateWrapper.cs +++ b/WoLua/Lua/Api/Game/FateWrapper.cs @@ -2,14 +2,13 @@ using Dalamud.Game.ClientState.Fates; -using FFXIVClientStructs.FFXIV.Client.Game.Fate; - using MoonSharp.Interpreter; using PrincessRTFM.WoLua.Constants; using PrincessRTFM.WoLua.Lua.Docs; using Fate = Dalamud.Game.ClientState.Fates.IFate; +using FateContext = FFXIVClientStructs.FFXIV.Client.Game.Fate.FateContext; namespace PrincessRTFM.WoLua.Lua.Api.Game; diff --git a/WoLua/Lua/Api/Game/MountWrapper.cs b/WoLua/Lua/Api/Game/MountWrapper.cs index 0496196..8f5aed9 100644 --- a/WoLua/Lua/Api/Game/MountWrapper.cs +++ b/WoLua/Lua/Api/Game/MountWrapper.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using Lumina.Excel; -using Lumina.Excel.GeneratedSheets; +using Lumina.Excel.Sheets; using MoonSharp.Interpreter; @@ -21,7 +21,7 @@ internal static void LoadGameData() { ExcelSheet mounts = Service.DataManager.GetExcelSheet()!; foreach (Mount mount in mounts) { - mountNames[(ushort)mount.RowId] = mount.Singular; + mountNames[(ushort)mount.RowId] = mount.Singular.ToString(); mountArticles[(ushort)mount.RowId] = "A" + (mount.StartsWithVowel > 0 ? "n" : string.Empty); } mountNames.Remove(0); diff --git a/WoLua/Lua/Api/Game/PlayerApi.cs b/WoLua/Lua/Api/Game/PlayerApi.cs index 6dbdf60..8bef462 100644 --- a/WoLua/Lua/Api/Game/PlayerApi.cs +++ b/WoLua/Lua/Api/Game/PlayerApi.cs @@ -10,7 +10,7 @@ using FFXIVClientStructs.FFXIV.Client.UI.Agent; using Lumina.Excel; -using Lumina.Excel.GeneratedSheets; +using Lumina.Excel.Sheets; using MoonSharp.Interpreter; @@ -252,7 +252,6 @@ internal PlayerApi(ScriptContainer source) : base(source) { } [LuaDoc("Provides three values consisting of the current character's X (east/west), Y (north/south), and Z (vertical) coordinates.", "If the player isn't loaded, all three values will be nil.", "This property is shorthand for `.Entity.MapCoords`.")] - [return: AsLuaType(LuaType.Number)] public DynValue MapCoords => this.Entity.MapCoords; [LuaPlayerDoc("The current character's rotation in radians, ranging from 0 to 2pi.", @@ -476,24 +475,24 @@ internal static void InitialiseEmotes() { ExcelSheet emotes = Service.DataManager.GameData.GetExcelSheet()!; try { - uint max = emotes.RowCount; + int max = emotes.Count; Service.Log.Information($"[{LogTag.Emotes}] Indexing {max:N0} emotes..."); for (uint i = 0; i < max; ++i) { - Emote? emote = emotes.GetRow(i); - if (emote is not null) { + Emote? emote = emotes.GetRowOrDefault(i); + if (emote.HasValue) { string[] commands = (new string?[] { - emote.Name.RawString, - emote.TextCommand.Value?.Command?.ToString(), - emote.TextCommand.Value?.ShortCommand?.ToString(), - emote.TextCommand.Value?.Alias?.ToString(), - emote.TextCommand.Value?.ShortAlias?.ToString(), + emote.Value.Name.ToString(), + emote.Value.TextCommand.ValueNullable?.Command.ToString(), + emote.Value.TextCommand.ValueNullable?.ShortCommand.ToString(), + emote.Value.TextCommand.ValueNullable?.Alias.ToString(), + emote.Value.TextCommand.ValueNullable?.ShortAlias.ToString(), }) .Where(s => !string.IsNullOrWhiteSpace(s)) .Cast() .Select(s => s.TrimStart('/')) .ToArray(); foreach (string command in commands) - emoteUnlocks[command] = emote.UnlockLink; + emoteUnlocks[command] = emote.Value.UnlockLink; } } Service.Log.Information($"[{LogTag.Emotes}] Cached {emoteUnlocks.Count:N0} emote names"); diff --git a/WoLua/Lua/Api/Game/WeatherWrapper.cs b/WoLua/Lua/Api/Game/WeatherWrapper.cs index b9116e5..9c77f3a 100644 --- a/WoLua/Lua/Api/Game/WeatherWrapper.cs +++ b/WoLua/Lua/Api/Game/WeatherWrapper.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using Lumina.Excel; -using Lumina.Excel.GeneratedSheets; +using Lumina.Excel.Sheets; using MoonSharp.Interpreter; @@ -56,8 +56,8 @@ internal static void LoadGameData() { if (Service.DataManager.GetExcelSheet() is ExcelSheet skies) { // Cache the names and descriptions for each type of weather foreach (Weather row in skies) { - weatherNames[row.RowId] = row.Name; - weatherDescriptions[row.RowId] = row.Description; + weatherNames[row.RowId] = row.Name.ToString(); + weatherDescriptions[row.RowId] = row.Description.ToString(); } Service.Log.Information($"[{LogTag.Weather}] Indexed {weatherNames.Count} weather types"); } diff --git a/WoLua/Lua/Api/Game/WorldPosition.cs b/WoLua/Lua/Api/Game/WorldPosition.cs index 43796fb..1ea5228 100644 --- a/WoLua/Lua/Api/Game/WorldPosition.cs +++ b/WoLua/Lua/Api/Game/WorldPosition.cs @@ -4,7 +4,7 @@ using Dalamud.Game.ClientState.Objects.Types; using Dalamud.Utility; -using Lumina.Excel.GeneratedSheets; +using Lumina.Excel.Sheets; using MoonSharp.Interpreter; @@ -46,10 +46,10 @@ internal Vector3? UiCoords { return null; uint zone = Service.ClientState.TerritoryType; if (zone > 0) { - Map? map = Service.DataManager.GetExcelSheet()!.GetRow(zone); - TerritoryTypeTransient? territoryTransient = Service.DataManager.GetExcelSheet()!.GetRow(zone); - if (map is not null && territoryTransient is not null) { - return MapUtil.WorldToMap(this.GameEnginePosition, map, territoryTransient, true); + Map? map = Service.DataManager.GetExcelSheet()!.GetRowOrDefault(zone); + TerritoryTypeTransient? territoryTransient = Service.DataManager.GetExcelSheet()!.GetRowOrDefault(zone); + if (map.HasValue && territoryTransient.HasValue) { + return MapUtil.WorldToMap(this.GameEnginePosition, map.Value, territoryTransient.Value, true); } } return null; diff --git a/WoLua/Plugin.cs b/WoLua/Plugin.cs index 8ce352e..7265c2c 100644 --- a/WoLua/Plugin.cs +++ b/WoLua/Plugin.cs @@ -13,7 +13,7 @@ using FFXIVClientStructs.FFXIV.Client.Game.Character; using FFXIVClientStructs.FFXIV.Client.Graphics.Environment; -using Lumina.Excel.GeneratedSheets; +using Lumina.Excel.Sheets; using MoonSharp.Interpreter; using MoonSharp.Interpreter.Platforms; @@ -24,8 +24,6 @@ using PrincessRTFM.WoLua.Ui; using PrincessRTFM.WoLua.Ui.Chat; -using XivCommon; - namespace PrincessRTFM.WoLua; public class Plugin: IDalamudPlugin { @@ -218,7 +216,7 @@ public void OnCommand(string command, string argline) { break; case "class": case "job": - if (Service.ClientState.LocalPlayer.ClassJob.GameData is ClassJob job) { + if (Service.ClientState.LocalPlayer.ClassJob.Value is ClassJob job) { this.Print($"You current job is {job.RowId} ({job.Abbreviation}, {job.Name}) at level {Service.ClientState.LocalPlayer.Level}."); } else { diff --git a/WoLua/dalamud.props b/WoLua/dalamud.props index 4465f75..92f7449 100644 --- a/WoLua/dalamud.props +++ b/WoLua/dalamud.props @@ -15,7 +15,7 @@ - + $(DalamudLibPath)Newtonsoft.Json.dll False diff --git a/WoLua/packages.lock.json b/WoLua/packages.lock.json index fe889b0..b5b1280 100644 --- a/WoLua/packages.lock.json +++ b/WoLua/packages.lock.json @@ -4,9 +4,9 @@ "net8.0-windows7.0": { "DalamudPackager": { "type": "Direct", - "requested": "[2.1.13, )", - "resolved": "2.1.13", - "contentHash": "rMN1omGe8536f4xLMvx9NwfvpAc9YFFfeXJ1t4P4PE6Gu8WCIoFliR1sh07hM+bfODmesk/dvMbji7vNI+B/pQ==" + "requested": "[11.0.0, )", + "resolved": "11.0.0", + "contentHash": "bjT7XUlhIJSmsE/O76b7weUX+evvGQctbQB8aKXt94o+oPWxHpCepxAGMs7Thow3AzCyqWs7cOpp9/2wcgRRQA==" }, "MoonSharp": { "type": "Direct", diff --git a/examples/03-local-chat-messages/command.lua b/examples/03-local-chat-messages/command.lua index 2d46e24..b8e6553 100644 --- a/examples/03-local-chat-messages/command.lua +++ b/examples/03-local-chat-messages/command.lua @@ -1,8 +1,8 @@ -Game.PrintChat("Yes, you can actually send chat messages on script load. It's not a GOOD idea, but you CAN do it.") +Game.PrintMessage("Yes, you can actually send chat messages on script load. It's not a GOOD idea, but you CAN do it.") Script(function() Game.PrintError("Oh no! This script prints an error when called!") - Game.PrintChat("Don't worry, nothing's actually wrong.") + Game.PrintMessage("Don't worry, nothing's actually wrong.") end) -- yeah, this example is really that simple