Skip to content

Commit c19d08b

Browse files
Add more detailed issue description on invalid manifest (closes #67)
1 parent f843c61 commit c19d08b

File tree

1 file changed

+32
-20
lines changed

1 file changed

+32
-20
lines changed

src/Loader.cs

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -99,30 +99,42 @@ internal static void LoadMods(Dictionary<string, Mod> mods)
9999
}
100100
}
101101

102-
if (manifest != null
103-
&& manifest.id != null
104-
&& Regex.IsMatch(manifest.id, @"^(?!polytopia$)[a-z_]+$")
105-
&& manifest.version != null
106-
&& manifest.authors != null
107-
&& manifest.authors.Length != 0
108-
)
102+
if (manifest == null)
109103
{
110-
if (mods.ContainsKey(manifest.id))
111-
{
112-
Plugin.logger.LogError($"Mod {manifest.id} already exists");
113-
continue;
114-
}
115-
mods.Add(manifest.id, new(
116-
manifest,
117-
Mod.Status.Success,
118-
files
119-
));
120-
Plugin.logger.LogInfo($"Registered mod {manifest.id}");
104+
Plugin.logger.LogError($"Mod manifest not found in {modContainer}");
105+
continue;
121106
}
122-
else
107+
if (manifest.id == null)
108+
{
109+
Plugin.logger.LogError($"Mod id not found in {modContainer}");
110+
continue;
111+
}
112+
if (!Regex.IsMatch(manifest.id, @"^(?!polytopia$)[a-z_]+$"))
113+
{
114+
Plugin.logger.LogError($"Mod id {manifest.id} is invalid in {modContainer}");
115+
continue;
116+
}
117+
if (manifest.version == null)
118+
{
119+
Plugin.logger.LogError($"Mod version not found in {modContainer}");
120+
continue;
121+
}
122+
if (manifest.authors == null || manifest.authors.Length == 0)
123+
{
124+
Plugin.logger.LogError($"Mod authors not found in {modContainer}");
125+
continue;
126+
}
127+
if (mods.ContainsKey(manifest.id))
123128
{
124-
Plugin.logger.LogError("An invalid mod manifest was found or not found at all");
129+
Plugin.logger.LogError($"Mod {manifest.id} already exists");
130+
continue;
125131
}
132+
mods.Add(manifest.id, new(
133+
manifest,
134+
Mod.Status.Success,
135+
files
136+
));
137+
Plugin.logger.LogInfo($"Registered mod {manifest.id}");
126138
}
127139

128140
foreach (var (id, mod) in mods)

0 commit comments

Comments
 (0)