Skip to content

Commit 269470e

Browse files
Merge pull request #214 from UchuServer/enhancement/script-dll-config
Improve configuration handling for ScriptDllSource
2 parents 9b16fb4 + 2179e3c commit 269470e

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

Uchu.Core/Config/UchuConfiguration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public class ServerDllSource
144144
/// <summary>
145145
/// The path to the Uchu.Instance DLL
146146
/// </summary>
147-
[XmlElement] public string Instance { get; set; } = "Uchu.Instance.dll";
147+
[XmlElement] public string Instance { get; set; } = "Enter path to Uchu.Instance.dll";
148148

149149
/// <summary>
150150
/// The path to the script source DLLs

Uchu.Master/MasterServer.cs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ private static async Task ConfigureAsync()
218218
{
219219
LogQueue.Config = Config = new UchuConfiguration();
220220

221+
Config.DllSource.ScriptDllSource.Add("Enter path to Uchu.StandardScripts.dll");
222+
221223
var backup = File.CreateText("config.default.xml");
222224

223225
serializer.Serialize(backup, Config);
@@ -265,10 +267,24 @@ private static async Task ConfigureAsync()
265267

266268
if (!File.Exists(DllLocation))
267269
{
268-
Logger.Error("Could not find file specified in DllSource -> Instance in config.xml.");
269-
throw new FileNotFoundException("Could not find Instance file.");
270+
throw new FileNotFoundException("Could not find file specified in <Instance> under <DllSource> in config.xml.");
270271
}
271272

273+
var validScriptPackExists = Config.DllSource.ScriptDllSource.Exists(scriptPackPath =>
274+
{
275+
if (File.Exists(scriptPackPath))
276+
return true;
277+
278+
Logger.Warning($"Could not find script pack at {scriptPackPath}");
279+
return false;
280+
});
281+
282+
if (!validScriptPackExists)
283+
{
284+
throw new FileNotFoundException("No valid <ScriptDllSource> specified under <DllSource> in config.xml.\n"
285+
+ "Without Uchu.StandardScripts.dll, Uchu cannot function correctly.");
286+
}
287+
272288
foreach (var scriptPackPath in Config.DllSource.ScriptDllSource)
273289
{
274290
if (!File.Exists(scriptPackPath))

0 commit comments

Comments
 (0)