Initial Commit
This commit is contained in:
commit
6032215d6b
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/.idea
|
||||
*.user
|
6
.gitmodules
vendored
Normal file
6
.gitmodules
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
[submodule "ECommons"]
|
||||
path = ECommons
|
||||
url = https://github.com/NightmareXIV/ECommons.git
|
||||
[submodule "AutoRetainerAPI"]
|
||||
path = AutoRetainerAPI
|
||||
url = https://github.com/PunishXIV/AutoRetainerAPI.git
|
1
AutoRetainerAPI
Submodule
1
AutoRetainerAPI
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 6f0aaa55bce6ec79fd4d72f84f21597b39e5445d
|
1
ECommons
Submodule
1
ECommons
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 79db61912cbfbb1627fc20a226ef02f8f0f7ad5c
|
28
Mariner.sln
Normal file
28
Mariner.sln
Normal file
@ -0,0 +1,28 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mariner", "Mariner\Mariner.csproj", "{A7868D94-660B-47C6-9660-85349E2313BD}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoRetainerAPI", "AutoRetainerAPI\AutoRetainerAPI\AutoRetainerAPI.csproj", "{0F9ED476-0313-4DB9-A7D1-0C3DBF025E56}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ECommons", "ECommons\ECommons\ECommons.csproj", "{CFE7B949-0364-4F27-8180-740A48943640}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{A7868D94-660B-47C6-9660-85349E2313BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A7868D94-660B-47C6-9660-85349E2313BD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A7868D94-660B-47C6-9660-85349E2313BD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A7868D94-660B-47C6-9660-85349E2313BD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{0F9ED476-0313-4DB9-A7D1-0C3DBF025E56}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{0F9ED476-0313-4DB9-A7D1-0C3DBF025E56}.Debug|Any CPU.Build.0 = Debug|x64
|
||||
{0F9ED476-0313-4DB9-A7D1-0C3DBF025E56}.Release|Any CPU.ActiveCfg = Release|x64
|
||||
{0F9ED476-0313-4DB9-A7D1-0C3DBF025E56}.Release|Any CPU.Build.0 = Release|x64
|
||||
{CFE7B949-0364-4F27-8180-740A48943640}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{CFE7B949-0364-4F27-8180-740A48943640}.Debug|Any CPU.Build.0 = Debug|x64
|
||||
{CFE7B949-0364-4F27-8180-740A48943640}.Release|Any CPU.ActiveCfg = Release|x64
|
||||
{CFE7B949-0364-4F27-8180-740A48943640}.Release|Any CPU.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
EndGlobal
|
1017
Mariner/.editorconfig
Normal file
1017
Mariner/.editorconfig
Normal file
File diff suppressed because it is too large
Load Diff
3
Mariner/.gitignore
vendored
Normal file
3
Mariner/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
/dist
|
||||
/obj
|
||||
/bin
|
65
Mariner/Mariner.csproj
Normal file
65
Mariner/Mariner.csproj
Normal file
@ -0,0 +1,65 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<Version>0.1</Version>
|
||||
<LangVersion>12</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
|
||||
<OutputPath>dist</OutputPath>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<DebugType>portable</DebugType>
|
||||
<PathMap Condition="$(SolutionDir) != ''">$(SolutionDir)=X:\</PathMap>
|
||||
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
|
||||
<DebugType>portable</DebugType>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<DalamudLibPath>$(appdata)\XIVLauncher\addon\Hooks\dev\</DalamudLibPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))'">
|
||||
<DalamudLibPath>$(DALAMUD_HOME)/</DalamudLibPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\AutoRetainerAPI\AutoRetainerAPI\AutoRetainerAPI.csproj"/>
|
||||
<ProjectReference Include="..\ECommons\ECommons\ECommons.csproj"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DalamudPackager" Version="2.1.12"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Dalamud">
|
||||
<HintPath>$(DalamudLibPath)Dalamud.dll</HintPath>
|
||||
<Private>false</Private>
|
||||
</Reference>
|
||||
<Reference Include="ImGui.NET">
|
||||
<HintPath>$(DalamudLibPath)ImGui.NET.dll</HintPath>
|
||||
<Private>false</Private>
|
||||
</Reference>
|
||||
<Reference Include="Lumina">
|
||||
<HintPath>$(DalamudLibPath)Lumina.dll</HintPath>
|
||||
<Private>false</Private>
|
||||
</Reference>
|
||||
<Reference Include="Lumina.Excel">
|
||||
<HintPath>$(DalamudLibPath)Lumina.Excel.dll</HintPath>
|
||||
<Private>false</Private>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath>$(DalamudLibPath)Newtonsoft.Json.dll</HintPath>
|
||||
<Private>false</Private>
|
||||
</Reference>
|
||||
<Reference Include="FFXIVClientStructs">
|
||||
<HintPath>$(DalamudLibPath)FFXIVClientStructs.dll</HintPath>
|
||||
<Private>false</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="RenameLatestZip" AfterTargets="PackagePlugin">
|
||||
<Exec Command="rename $(OutDir)$(AssemblyName)\latest.zip $(AssemblyName)-$(Version).zip"/>
|
||||
</Target>
|
||||
</Project>
|
8
Mariner/Mariner.json
Normal file
8
Mariner/Mariner.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"Name": "Mariner",
|
||||
"Author": "Liza Carvelli",
|
||||
"Punchline": "Somewhat basic sub levelling",
|
||||
"Description": "",
|
||||
"RepoUrl": "https://git.carvel.li/liza/Mariner",
|
||||
"IconUrl": "https://plugins.carvel.li/icons/Mariner.png"
|
||||
}
|
102
Mariner/MarinerPlugin.cs
Normal file
102
Mariner/MarinerPlugin.cs
Normal file
@ -0,0 +1,102 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using AutoRetainerAPI;
|
||||
using AutoRetainerAPI.Configuration;
|
||||
using Dalamud.Game.Command;
|
||||
using Dalamud.Plugin;
|
||||
using Dalamud.Plugin.Services;
|
||||
using ECommons;
|
||||
|
||||
namespace Mariner;
|
||||
|
||||
[SuppressMessage("ReSharper", "UnusedType.Global")]
|
||||
public sealed class MarinerPlugin : IDalamudPlugin
|
||||
{
|
||||
private readonly IClientState _clientState;
|
||||
private readonly IFramework _framework;
|
||||
private readonly ICommandManager _commandManager;
|
||||
private readonly IPluginLog _pluginLog;
|
||||
private readonly AutoRetainerApi _autoRetainerApi;
|
||||
|
||||
public MarinerPlugin(DalamudPluginInterface pluginInterface, IClientState clientState, IFramework framework,
|
||||
ICommandManager commandManager, IChatGui chatGui, IPluginLog pluginLog)
|
||||
{
|
||||
_clientState = clientState;
|
||||
_framework = framework;
|
||||
_commandManager = commandManager;
|
||||
_pluginLog = pluginLog;
|
||||
|
||||
ECommonsMain.Init(pluginInterface, this);
|
||||
_autoRetainerApi = new AutoRetainerApi();
|
||||
|
||||
_clientState.Login += ReassignSubmarinesOnLogin;
|
||||
_commandManager.AddHandler("/mariner", new CommandInfo((_, _) =>
|
||||
{
|
||||
string v = ReassignSubmarines();
|
||||
chatGui.Print($"[Mariner] {v}");
|
||||
}));
|
||||
|
||||
if (_clientState.IsLoggedIn)
|
||||
ReassignSubmarinesOnLogin();
|
||||
}
|
||||
|
||||
private void ReassignSubmarinesOnLogin()
|
||||
{
|
||||
_framework.RunOnFrameworkThread(() =>
|
||||
{
|
||||
string v = ReassignSubmarines();
|
||||
_pluginLog.Information(v);
|
||||
});
|
||||
}
|
||||
|
||||
private string ReassignSubmarines()
|
||||
{
|
||||
ulong contentId = _clientState.LocalContentId;
|
||||
if (contentId == 0)
|
||||
return "No content id";
|
||||
|
||||
OfflineCharacterData? offlineCharacterData = _autoRetainerApi.GetOfflineCharacterData(contentId);
|
||||
if (offlineCharacterData == null)
|
||||
return "Not updating subs, no OCD";
|
||||
|
||||
if (!offlineCharacterData.WorkshopEnabled)
|
||||
return "Not updating subs, character not enabled";
|
||||
|
||||
if (offlineCharacterData.EnabledSubs.Count != 4)
|
||||
return "Not updating subs, not all subs are enabled";
|
||||
|
||||
if (offlineCharacterData.AdditionalSubmarineData.All(x =>
|
||||
x.Value.Level >= 115 && x.Value.VesselBehavior == VesselBehavior.Use_plan))
|
||||
return "Not updating subs, all subs are level 115+ and use plans";
|
||||
|
||||
var subs = offlineCharacterData.AdditionalSubmarineData.Values
|
||||
.OrderBy(x => x.Level)
|
||||
.ThenBy(x => x.CurrentExp)
|
||||
.ToList();
|
||||
for (int i = 0; i < subs.Count; ++i)
|
||||
{
|
||||
var sub = subs[i];
|
||||
sub.VesselBehavior = sub.Level switch
|
||||
{
|
||||
< 101 => VesselBehavior.Unlock,
|
||||
>= 115 => VesselBehavior.Use_plan,
|
||||
_ when i == 0 => VesselBehavior.Unlock,
|
||||
_ => VesselBehavior.Use_plan
|
||||
};
|
||||
}
|
||||
|
||||
_autoRetainerApi.WriteOfflineCharacterData(offlineCharacterData);
|
||||
|
||||
var vessel = offlineCharacterData.AdditionalSubmarineData.Single(x => x.Value == subs[0]);
|
||||
return $"Lowest sub: {vessel.Key} → {subs[0].VesselBehavior}";
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_commandManager.RemoveHandler("/mariner");
|
||||
_clientState.Login -= ReassignSubmarinesOnLogin;
|
||||
|
||||
_autoRetainerApi.Dispose();
|
||||
ECommonsMain.Dispose();
|
||||
}
|
||||
}
|
22
Mariner/packages.lock.json
Normal file
22
Mariner/packages.lock.json
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"version": 1,
|
||||
"dependencies": {
|
||||
"net8.0-windows7.0": {
|
||||
"DalamudPackager": {
|
||||
"type": "Direct",
|
||||
"requested": "[2.1.12, )",
|
||||
"resolved": "2.1.12",
|
||||
"contentHash": "Sc0PVxvgg4NQjcI8n10/VfUQBAS4O+Fw2pZrAqBdRMbthYGeogzu5+xmIGCGmsEZ/ukMOBuAqiNiB5qA3MRalg=="
|
||||
},
|
||||
"autoretainerapi": {
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"ECommons": "[2.1.0.7, )"
|
||||
}
|
||||
},
|
||||
"ecommons": {
|
||||
"type": "Project"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user