Skip to content

Commit

Permalink
Different ModTek detection code.
Browse files Browse the repository at this point in the history
  • Loading branch information
CptMoore committed Dec 14, 2019
1 parent 89d9e59 commit 9b5ab4f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions source/Control.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using HBS.Logging;
using HBS.Util;
using System;
using System.Linq;
using System.Reflection;

namespace NewSaveFolder
Expand All @@ -16,8 +17,8 @@ public static void Start(string modDirectory, string json)
{
try
{
var isModTek = Type.GetType("ModTek.ModTek") != null;
if (!isModTek)
var hasModTek = GetAssemblyByName("ModTek") != null;
if (!hasModTek)
{
throw new InvalidOperationException("This mod is for ModTek only and does not run under ModLoader");
}
Expand All @@ -41,5 +42,10 @@ public static void Start(string modDirectory, string json)
Control.Logger.LogError(e);
}
}

private static Assembly GetAssemblyByName(string name)
{
return AppDomain.CurrentDomain.GetAssemblies().SingleOrDefault(assembly => assembly.GetName().Name == name);
}
}
}

0 comments on commit 9b5ab4f

Please sign in to comment.