mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Implement command completion suggestions.
This commit is contained in:
parent
5d2589b10f
commit
84cf749344
115 changed files with 4684 additions and 2695 deletions
|
|
@ -4,34 +4,36 @@ using System.Reflection;
|
|||
|
||||
namespace MinecraftClient.Scripting;
|
||||
|
||||
public static class AssemblyResolver {
|
||||
public static class AssemblyResolver
|
||||
{
|
||||
private static Dictionary<string, string> ScriptAssemblies = new();
|
||||
static AssemblyResolver() {
|
||||
static AssemblyResolver()
|
||||
{
|
||||
// Manually resolve assemblies that .NET can't resolve automatically.
|
||||
AppDomain.CurrentDomain.AssemblyResolve += (sender, args) =>
|
||||
AppDomain.CurrentDomain.AssemblyResolve += (sender, args) =>
|
||||
{
|
||||
var asmReqName = new AssemblyName(args.Name);
|
||||
|
||||
// Check the script-referenced assemblies if we have the DLL that is required.
|
||||
foreach (var dll in ScriptAssemblies)
|
||||
{
|
||||
// If we have the assembly, load it.
|
||||
if (asmReqName.FullName == dll.Key)
|
||||
{
|
||||
return Assembly.LoadFile(dll.Value);
|
||||
}
|
||||
}
|
||||
var asmReqName = new AssemblyName(args.Name);
|
||||
|
||||
ConsoleIO.WriteLogLine($"[Script Error] Failed to resolve assembly {args.Name} (are you missing a DLL file?)");
|
||||
return null;
|
||||
};
|
||||
// Check the script-referenced assemblies if we have the DLL that is required.
|
||||
foreach (var dll in ScriptAssemblies)
|
||||
{
|
||||
// If we have the assembly, load it.
|
||||
if (asmReqName.FullName == dll.Key)
|
||||
{
|
||||
return Assembly.LoadFile(dll.Value);
|
||||
}
|
||||
}
|
||||
|
||||
ConsoleIO.WriteLogLine($"[Script Error] Failed to resolve assembly {args.Name} (are you missing a DLL file?)");
|
||||
return null;
|
||||
};
|
||||
}
|
||||
|
||||
internal static void AddAssembly(string AssemblyFullName, string AssemblyPath)
|
||||
internal static void AddAssembly(string AssemblyFullName, string AssemblyPath)
|
||||
{
|
||||
if (ScriptAssemblies.ContainsKey(AssemblyFullName))
|
||||
return;
|
||||
|
||||
|
||||
ScriptAssemblies.Add(AssemblyFullName, AssemblyPath);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue