Skip to content

Commit

Permalink
export only an alarm list instead of the whole object
Browse files Browse the repository at this point in the history
  • Loading branch information
xorus committed Jan 16, 2024
1 parent 8cdffaf commit 58ba537
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Plugin/EngageTimer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<ItemGroup>
<PackageReference Include="DalamudPackager" Version="2.1.12"/>
<PackageReference Include="EmbedIO" Version="3.5.2"/>
<PackageReference Include="JetBrains.Annotations" Version="2023.2.0"/>
<PackageReference Include="JetBrains.Annotations" Version="2023.3.0" />
<!-- required for Unosquare.Swan.Lite (implicit dependency of EmbedIO) -->
<PackageReference Include="System.ValueTuple" Version="4.5.0"/>
<PackageReference Include="Unosquare.Swan.Lite" Version="3.1.0"/>
Expand Down
10 changes: 6 additions & 4 deletions Plugin/Status/CombatAlarm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Dalamud.Game.Text;
using Dalamud.Interface.Internal.Notifications;
using Dalamud.Plugin.Services;
Expand Down Expand Up @@ -58,14 +59,14 @@ public CombatAlarm()
try
{
var text = File.ReadAllText(fileName);
var data = JsonConvert.DeserializeObject<CombatAlarmsConfiguration>(text,
var data = JsonConvert.DeserializeObject<List<CombatAlarmsConfiguration.Alarm>>(text,
new JsonSerializerSettings
{
// using "TypeNameHandling.Objects" causes a "resolving to a collectible assembly is not supported"
TypeNameHandling = TypeNameHandling.None
});
if (data == null || data.Alarms.Count == 0) return Translator.Tr("CombatAlarm_ImportedEmpty");
Plugin.Config.CombatAlarms.Alarms.AddRange(data.Alarms);
if (data == null || data.Count == 0) return Translator.Tr("CombatAlarm_ImportedEmpty");
Plugin.Config.CombatAlarms.Alarms.AddRange(data);
}
catch (JsonSerializationException e)
{
Expand All @@ -86,7 +87,8 @@ public CombatAlarm()
try
{
File.WriteAllText(fileName,
JsonConvert.SerializeObject(Plugin.Config.CombatAlarms, Formatting.Indented,
JsonConvert.SerializeObject(Plugin.Config.CombatAlarms.Alarms.Where(alarm => alarm.Enabled).ToList(),
Formatting.Indented,
new JsonSerializerSettings
{
TypeNameHandling = TypeNameHandling.None
Expand Down
6 changes: 3 additions & 3 deletions Plugin/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
},
"JetBrains.Annotations": {
"type": "Direct",
"requested": "[2023.2.0, )",
"resolved": "2023.2.0",
"contentHash": "dvO//8aLmLRsCVVgoc/7qBqi2/y4BTyRcg20LCBWtK4n6E9Um06Zp7jF1n0hOE+yqBHwcrDzAjWvCaM3qH8flg=="
"requested": "[2023.3.0, )",
"resolved": "2023.3.0",
"contentHash": "PHfnvdBUdGaTVG9bR/GEfxgTwWM0Z97Y6X3710wiljELBISipSfF5okn/vz+C2gfO+ihoEyVPjaJwn8ZalVukA=="
},
"System.ValueTuple": {
"type": "Direct",
Expand Down

0 comments on commit 58ba537

Please sign in to comment.