<commit_before>using System;
using System.Reflection;
using UnityEngine;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json.Linq;

namespace Nuterra
{
	public sealed class ModLoader
	{
		public static ModLoader Instance { get; } = new ModLoader();

		private Dictionary<Type, TerraTechMod> _modInstances = new Dictionary<Type, TerraTechMod>();
		private Dictionary<string, Type> _modNames = new Dictionary<string, Type>();

		public void LoadAllMods(Assembly asm)
		{
			foreach (Type modClass in asm.GetExportedTypes().Where(IsModClass))
			{
				LoadMod(modClass);
			}
		}

		private bool IsModClass(Type modType)
		{
			if (modType == null) return false;
			if (!typeof(TerraTechMod).IsAssignableFrom(modType)) return false;
			if (!modType.IsClass) return false;
			if (modType.IsAbstract) return false;

			//Now start displaying warnings for missing requirements
			ConstructorInfo ctor = modType.GetConstructor(Type.EmptyTypes);
			if (ctor == null)
			{
				Console.WriteLine($"The mod '{modType.Name}' does not have a parameterless constructor and will not be launched");
				return false;
			}
			return true;
		}

		private void LoadMod(Type modClass)
		{
			TerraTechMod mod = EnsureModInstance(modClass);
			Console.WriteLine($"Loading mod: {mod.Name} (v{mod.Version})");
			mod.Load();
		}

		private TerraTechMod EnsureModInstance(Type modClass)
		{
			TerraTechMod mod;
			if (!_modInstances.TryGetValue(modClass, out mod))
			{
				Console.WriteLine($"Creating mod instance '{modClass.Name}'");
				mod = (TerraTechMod)Activator.CreateInstance(modClass);
				_modInstances.Add(modClass, mod);
			}
			return mod;
		}

		public TerraTechMod GetMod(string name)
		{
			Type modType = _modNames[name];
			return _modInstances[modType];
		}

		public T GetMod<T>() where T : TerraTechMod
		{
			return (T)_modInstances[typeof(T)];
		}
	}
}<commit_msg>Fixed mods not being registered by name<commit_after>using System;
using System.Reflection;
using UnityEngine;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json.Linq;

namespace Nuterra
{
	public sealed class ModLoader
	{
		public static ModLoader Instance { get; } = new ModLoader();

		private Dictionary<Type, TerraTechMod> _modInstances = new Dictionary<Type, TerraTechMod>();
		private Dictionary<string, Type> _modNames = new Dictionary<string, Type>();

		public void LoadAllMods(Assembly asm)
		{
			foreach (Type modClass in asm.GetExportedTypes().Where(IsModClass))
			{
				LoadMod(modClass);
			}
		}

		private bool IsModClass(Type modType)
		{
			if (modType == null) return false;
			if (!typeof(TerraTechMod).IsAssignableFrom(modType)) return false;
			if (!modType.IsClass) return false;
			if (modType.IsAbstract) return false;

			//Now start displaying warnings for missing requirements
			ConstructorInfo ctor = modType.GetConstructor(Type.EmptyTypes);
			if (ctor == null)
			{
				Console.WriteLine($"The mod '{modType.Name}' does not have a parameterless constructor and will not be launched");
				return false;
			}
			return true;
		}

		private void LoadMod(Type modClass)
		{
			TerraTechMod mod = EnsureModInstance(modClass);
			Console.WriteLine($"Loading mod: {mod.Name} (v{mod.Version})");
			mod.Load();
		}

		private TerraTechMod EnsureModInstance(Type modClass)
		{
			TerraTechMod mod;
			if (!_modInstances.TryGetValue(modClass, out mod))
			{
				Console.WriteLine($"Creating mod instance '{modClass.Name}'");
				mod = (TerraTechMod)Activator.CreateInstance(modClass);
				_modInstances.Add(modClass, mod);
				_modNames.Add(mod.Name, modClass);
			}
			return mod;
		}

		public TerraTechMod GetMod(string name)
		{
			Type modType = _modNames[name];
			return _modInstances[modType];
		}

		public T GetMod<T>() where T : TerraTechMod
		{
			return (T)_modInstances[typeof(T)];
		}
	}
}
{'fraction_non_alphanumeric': 0.11056826947801492, 'fraction_numerical': 0.0, 'mean_word_length': 4.2638700947225985, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4299400', 'n_tokens_mistral': 1434, 'n_tokens_neox': 1229, 'n_words': 312}