Skip to content

Commit 95618ce

Browse files
committed
Fix bug when editing a part's field
1 parent f0c991b commit 95618ce

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

plugin_template/swinfo.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"name": "Patch Manager",
66
"description": "A mod for generic patching needs similar to KSP 1's Module Manager.",
77
"source": "https://github.com/KSP2Community/PatchManager",
8-
"version": "0.10.0",
8+
"version": "0.10.1",
99
"version_check": "https://raw.githubusercontent.com/KSP2Community/PatchManager/main/plugin_template/swinfo.json",
1010
"ksp2_version": {
1111
"min": "0.2.0",

src/PatchManager.Parts/Modifiables/PartModifiable.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,18 @@ public override DataValue GetFieldValue(string fieldName)
2323
var repl = fieldName.Replace("PartComponent", "");
2424
if (JToken is not JObject jObject)
2525
return DataValue.Null;
26-
if(!jObject.ContainsKey("serializedPartModules"))
26+
if (!jObject.ContainsKey("serializedPartModules"))
2727
return DataValue.Null;
2828
foreach (var module in jObject["serializedPartModules"])
2929
{
30-
if (module is not JObject moduleObject)continue;
30+
if (module is not JObject moduleObject) continue;
3131
if (moduleObject.ContainsKey("Name") && ((string)moduleObject["Name"])!.Replace("PartComponent", "") == repl)
3232
return DataValue.FromJToken(module);
3333
}
34+
35+
if (jObject.TryGetValue(fieldName, out var value))
36+
return DataValue.FromJToken(value);
37+
3438
return DataValue.Null;
3539
}
3640

0 commit comments

Comments
 (0)