Skip to content

Commit 5c1a611

Browse files
authored
Merge pull request Pryaxis#249 from ZakFahey/additional-plugins
Allow multiple additional plugin paths
2 parents e0e2df2 + 17e7a81 commit 5c1a611

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

TerrariaServerAPI/TerrariaApi.Server/ServerApi.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using TerrariaApi.Reporting;
1010
using System.Reflection.PortableExecutable;
1111
using System.Runtime.InteropServices;
12+
using System.Collections.Immutable;
1213

1314
namespace TerrariaApi.Server
1415
{
@@ -18,8 +19,15 @@ namespace TerrariaApi.Server
1819
public static class ServerApi
1920
{
2021
public const string PluginsPath = "ServerPlugins";
21-
public static string? AdditionalPluginsPath { get; private set; } = null;
2222

23+
/// <summary>
24+
/// Returns the first value from <see cref="AdditionalPluginsPaths"/> if it exists, otherwise null.
25+
/// </summary>
26+
[Obsolete("Use AdditionalPluginsPaths instead", error: false)]
27+
public static string? AdditionalPluginsPath => AdditionalPluginsPaths.FirstOrDefault();
28+
29+
/// <summary> A list of all plugin paths specified by the -additionalplugins flag. </summary>
30+
public static ImmutableList<string> AdditionalPluginsPaths { get; private set; } = ImmutableList.Create<string>();
2331
public static readonly Version ApiVersion = new Version(2, 1, 0, 0);
2432
private static Main game;
2533
private static readonly Dictionary<string, Assembly> loadedAssemblies = new Dictionary<string, Assembly>();
@@ -265,7 +273,7 @@ internal static void HandleCommandLine(string[] parms)
265273
CrashReporter.crashReportPath = arg.Value;
266274
break;
267275
case "-additionalplugins":
268-
AdditionalPluginsPath = arg.Value;
276+
AdditionalPluginsPaths = arg.Value.Split(',').ToImmutableList();
269277
break;
270278
}
271279
}
@@ -310,7 +318,7 @@ internal static void LoadPlugins()
310318

311319
List<FileInfo> fileInfos = new DirectoryInfo(ServerPluginsDirectoryPath).GetFiles("*.dll").ToList();
312320
fileInfos.AddRange(new DirectoryInfo(ServerPluginsDirectoryPath).GetFiles("*.dll-plugin"));
313-
if (AdditionalPluginsPath is string additionalPath)
321+
foreach (string additionalPath in AdditionalPluginsPaths)
314322
{
315323
var di = new DirectoryInfo(Path.Combine(AppContext.BaseDirectory, additionalPath));
316324
fileInfos.AddRange(di.GetFiles("*.dll"));

0 commit comments

Comments
 (0)