Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
0d889172bb | |||
25d25ccf6b |
@ -990,7 +990,7 @@ csharp_space_around_binary_operators = before_and_after
|
|||||||
csharp_using_directive_placement = outside_namespace:silent
|
csharp_using_directive_placement = outside_namespace:silent
|
||||||
csharp_prefer_simple_using_statement = true:suggestion
|
csharp_prefer_simple_using_statement = true:suggestion
|
||||||
csharp_prefer_braces = true:silent
|
csharp_prefer_braces = true:silent
|
||||||
csharp_style_namespace_declarations = block_scoped:silent
|
csharp_style_namespace_declarations = file_scoped:suggestion
|
||||||
csharp_style_prefer_method_group_conversion = true:silent
|
csharp_style_prefer_method_group_conversion = true:silent
|
||||||
csharp_style_prefer_top_level_statements = true:silent
|
csharp_style_prefer_top_level_statements = true:silent
|
||||||
csharp_style_prefer_primary_constructors = true:suggestion
|
csharp_style_prefer_primary_constructors = true:suggestion
|
||||||
|
62
RetainerTrack/Commands/AccountIdCommand.cs
Normal file
62
RetainerTrack/Commands/AccountIdCommand.cs
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
using System;
|
||||||
|
using Dalamud.Game.ClientState.Objects;
|
||||||
|
using Dalamud.Game.ClientState.Objects.Enums;
|
||||||
|
using Dalamud.Game.ClientState.Objects.Types;
|
||||||
|
using Dalamud.Game.Command;
|
||||||
|
using Dalamud.Plugin.Services;
|
||||||
|
using FFXIVClientStructs.FFXIV.Client.Game.Character;
|
||||||
|
using RetainerTrack.Handlers;
|
||||||
|
|
||||||
|
namespace RetainerTrack.Commands
|
||||||
|
{
|
||||||
|
internal sealed class AccountIdCommand : IDisposable
|
||||||
|
{
|
||||||
|
private readonly ICommandManager _commandManager;
|
||||||
|
private readonly IClientState _clientState;
|
||||||
|
private readonly ITargetManager _targetManager;
|
||||||
|
private readonly IChatGui _chatGui;
|
||||||
|
private readonly PersistenceContext _persistenceContext;
|
||||||
|
|
||||||
|
public AccountIdCommand(ICommandManager commandManager, IClientState clientState, ITargetManager targetManager,
|
||||||
|
IChatGui chatGui, PersistenceContext persistenceContext)
|
||||||
|
{
|
||||||
|
_commandManager = commandManager;
|
||||||
|
_clientState = clientState;
|
||||||
|
_targetManager = targetManager;
|
||||||
|
_chatGui = chatGui;
|
||||||
|
_persistenceContext = persistenceContext;
|
||||||
|
|
||||||
|
_commandManager.AddHandler("/accountid", new CommandInfo(ProcessCommand)
|
||||||
|
{
|
||||||
|
HelpMessage = "Shows the accountid of your target (or if no target, yourself)"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ProcessCommand(string command, string arguments)
|
||||||
|
{
|
||||||
|
IGameObject? character = _targetManager.Target ?? _clientState.LocalPlayer;
|
||||||
|
if (character == null || character.ObjectKind != ObjectKind.Player)
|
||||||
|
return;
|
||||||
|
|
||||||
|
unsafe
|
||||||
|
{
|
||||||
|
var bc = (BattleChara*)character.Address;
|
||||||
|
_chatGui.Print($"{character.Name} has Account Id: {bc->AccountId}, Content Id: {bc->ContentId}");
|
||||||
|
|
||||||
|
_persistenceContext.HandleContentIdMapping([
|
||||||
|
new PlayerMapping
|
||||||
|
{
|
||||||
|
ContentId = bc->ContentId,
|
||||||
|
AccountId = bc->AccountId,
|
||||||
|
PlayerName = bc->NameString,
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
_commandManager.RemoveHandler("/accountid");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -46,15 +46,13 @@ internal sealed class ObjectTableHandler : IDisposable
|
|||||||
if (obj.ObjectKind == ObjectKind.Player)
|
if (obj.ObjectKind == ObjectKind.Player)
|
||||||
{
|
{
|
||||||
var bc = (BattleChara*)obj.Address;
|
var bc = (BattleChara*)obj.Address;
|
||||||
var ep = (ExtendedPlayer*)obj.Address;
|
if (bc->ContentId == 0 || bc->AccountId == 0)
|
||||||
|
|
||||||
if (ep->ContentId == 0 || ep->AccountId == 0)
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
playerMappings.Add(new PlayerMapping
|
playerMappings.Add(new PlayerMapping
|
||||||
{
|
{
|
||||||
ContentId = ep->ContentId,
|
ContentId = bc->ContentId,
|
||||||
AccountId = ep->AccountId,
|
AccountId = bc->AccountId,
|
||||||
PlayerName = bc->NameString,
|
PlayerName = bc->NameString,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -70,11 +68,4 @@ internal sealed class ObjectTableHandler : IDisposable
|
|||||||
{
|
{
|
||||||
_framework.Update -= FrameworkUpdate;
|
_framework.Update -= FrameworkUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Explicit, Size = 0x2280)]
|
|
||||||
public struct ExtendedPlayer
|
|
||||||
{
|
|
||||||
[FieldOffset(0x2258)] public ulong AccountId;
|
|
||||||
[FieldOffset(0x2260)] public ulong ContentId;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<Project Sdk="Dalamud.NET.Sdk/9.0.2">
|
<Project Sdk="Dalamud.NET.Sdk/9.0.2">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Version>4.1</Version>
|
<Version>4.3</Version>
|
||||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||||
<SatelliteResourceLanguages>none</SatelliteResourceLanguages>
|
<SatelliteResourceLanguages>none</SatelliteResourceLanguages>
|
||||||
<OutputPath Condition="'$(Configuration)' != 'EF'">dist</OutputPath>
|
<OutputPath Condition="'$(Configuration)' != 'EF'">dist</OutputPath>
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using Dalamud.Extensions.MicrosoftLogging;
|
using Dalamud.Extensions.MicrosoftLogging;
|
||||||
|
using Dalamud.Game.ClientState.Objects;
|
||||||
using Dalamud.Plugin;
|
using Dalamud.Plugin;
|
||||||
using Dalamud.Plugin.Services;
|
using Dalamud.Plugin.Services;
|
||||||
using Microsoft.Data.Sqlite;
|
using Microsoft.Data.Sqlite;
|
||||||
@ -31,6 +32,7 @@ internal sealed class RetainerTrackPlugin : IDalamudPlugin
|
|||||||
IAddonLifecycle addonLifecycle,
|
IAddonLifecycle addonLifecycle,
|
||||||
ICommandManager commandManager,
|
ICommandManager commandManager,
|
||||||
IDataManager dataManager,
|
IDataManager dataManager,
|
||||||
|
ITargetManager targetManager,
|
||||||
IObjectTable objectTable,
|
IObjectTable objectTable,
|
||||||
IMarketBoard marketBoard,
|
IMarketBoard marketBoard,
|
||||||
IPluginLog pluginLog)
|
IPluginLog pluginLog)
|
||||||
@ -50,6 +52,7 @@ internal sealed class RetainerTrackPlugin : IDalamudPlugin
|
|||||||
serviceCollection.AddSingleton(addonLifecycle);
|
serviceCollection.AddSingleton(addonLifecycle);
|
||||||
serviceCollection.AddSingleton(commandManager);
|
serviceCollection.AddSingleton(commandManager);
|
||||||
serviceCollection.AddSingleton(dataManager);
|
serviceCollection.AddSingleton(dataManager);
|
||||||
|
serviceCollection.AddSingleton(targetManager);
|
||||||
serviceCollection.AddSingleton(objectTable);
|
serviceCollection.AddSingleton(objectTable);
|
||||||
serviceCollection.AddSingleton(marketBoard);
|
serviceCollection.AddSingleton(marketBoard);
|
||||||
|
|
||||||
@ -58,24 +61,24 @@ internal sealed class RetainerTrackPlugin : IDalamudPlugin
|
|||||||
serviceCollection.AddSingleton<MarketBoardUiHandler>();
|
serviceCollection.AddSingleton<MarketBoardUiHandler>();
|
||||||
serviceCollection.AddSingleton<ObjectTableHandler>();
|
serviceCollection.AddSingleton<ObjectTableHandler>();
|
||||||
serviceCollection.AddSingleton<GameHooks>();
|
serviceCollection.AddSingleton<GameHooks>();
|
||||||
|
serviceCollection.AddSingleton<AccountIdCommand>();
|
||||||
serviceCollection.AddSingleton<WhoCommand>();
|
serviceCollection.AddSingleton<WhoCommand>();
|
||||||
|
|
||||||
_sqliteConnectionString =
|
_sqliteConnectionString = PrepareSqliteDb(serviceCollection, pluginInterface.GetPluginConfigDirectory());
|
||||||
$"Data Source={Path.Join(pluginInterface.GetPluginConfigDirectory(), DatabaseFileName)}";
|
|
||||||
serviceCollection.AddDbContext<RetainerTrackContext>(o => o
|
|
||||||
.UseSqlite(_sqliteConnectionString)
|
|
||||||
.UseModel(RetainerTrackContextModel.Instance));
|
|
||||||
|
|
||||||
_serviceProvider = serviceCollection.BuildServiceProvider();
|
_serviceProvider = serviceCollection.BuildServiceProvider();
|
||||||
|
|
||||||
|
|
||||||
RunMigrations(_serviceProvider);
|
RunMigrations(_serviceProvider);
|
||||||
|
InitializeRequiredServices(_serviceProvider);
|
||||||
|
}
|
||||||
|
|
||||||
_serviceProvider.GetRequiredService<MarketBoardOfferingsHandler>();
|
private static string PrepareSqliteDb(IServiceCollection serviceCollection, string getPluginConfigDirectory)
|
||||||
_serviceProvider.GetRequiredService<MarketBoardUiHandler>();
|
{
|
||||||
_serviceProvider.GetRequiredService<ObjectTableHandler>();
|
string connectionString = $"Data Source={Path.Join(getPluginConfigDirectory, DatabaseFileName)}";
|
||||||
_serviceProvider.GetRequiredService<GameHooks>();
|
serviceCollection.AddDbContext<RetainerTrackContext>(o => o
|
||||||
_serviceProvider.GetRequiredService<WhoCommand>();
|
.UseSqlite(connectionString)
|
||||||
|
.UseModel(RetainerTrackContextModel.Instance));
|
||||||
|
return connectionString;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void RunMigrations(IServiceProvider serviceProvider)
|
private static void RunMigrations(IServiceProvider serviceProvider)
|
||||||
@ -85,6 +88,16 @@ internal sealed class RetainerTrackPlugin : IDalamudPlugin
|
|||||||
dbContext.Database.Migrate();
|
dbContext.Database.Migrate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void InitializeRequiredServices(ServiceProvider serviceProvider)
|
||||||
|
{
|
||||||
|
serviceProvider.GetRequiredService<MarketBoardOfferingsHandler>();
|
||||||
|
serviceProvider.GetRequiredService<MarketBoardUiHandler>();
|
||||||
|
serviceProvider.GetRequiredService<ObjectTableHandler>();
|
||||||
|
serviceProvider.GetRequiredService<GameHooks>();
|
||||||
|
serviceProvider.GetRequiredService<AccountIdCommand>();
|
||||||
|
serviceProvider.GetRequiredService<WhoCommand>();
|
||||||
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
_serviceProvider?.Dispose();
|
_serviceProvider?.Dispose();
|
||||||
|
Loading…
Reference in New Issue
Block a user