Skip to content

Instantly share code, notes, and snippets.

@NimbusFox
Created February 23, 2018 22:43
Show Gist options
  • Save NimbusFox/973420c592080cb9a3fbe79861fb123e to your computer and use it in GitHub Desktop.
Save NimbusFox/973420c592080cb9a3fbe79861fb123e to your computer and use it in GitHub Desktop.
static Static() {
var dir = Assembly.GetExecutingAssembly().Location;
foreach (var file in new DirectoryInfo(dir).GetFiles("*.mod")) {
var data = JsonConvert.DeserializeObject<Dictionary<string, object>>(File.ReadAllText(file.FullName));
if (data.Any(x => x.Key.ToLower() == "landclaim")) {
var current = data[data.First(x => x.Key.ToLower() == "landclaim").Key];
if (current is bool b) {
if (b) {
var item = Assembly.LoadFile(file.FullName.Replace(".mod", ".dll"));
foreach (var module in item.GetModules()) {
if (module.GetType() is ILandClaim) {
LandClaim = (ILandClaim) Activator.CreateInstance(module.GetType());
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment