Plugin.Load should take path instead of name

This commit is contained in:
UnknownShadow200 2020-06-14 19:41:38 +10:00
parent 3aac7112c9
commit 6b83f56b1e
3 changed files with 6 additions and 13 deletions

View File

@ -71,7 +71,7 @@ namespace MCGalaxy.Commands.Scripting {
static void LoadPlugin(Player p, string name) { static void LoadPlugin(Player p, string name) {
string path = IScripting.PluginPath(name); string path = IScripting.PluginPath(name);
if (File.Exists(path)) { if (File.Exists(path)) {
if (Plugin.Load(name, false)) { if (Plugin.Load(path, false)) {
p.Message("Plugin loaded successfully."); p.Message("Plugin loaded successfully.");
} else { } else {
p.Message("%WError loading plugin. See error logs for more information."); p.Message("%WError loading plugin. See error logs for more information.");

View File

@ -28,12 +28,10 @@ namespace MCGalaxy {
internal static List<Plugin> core = new List<Plugin>(); internal static List<Plugin> core = new List<Plugin>();
public static List<Plugin> all = new List<Plugin>(); public static List<Plugin> all = new List<Plugin>();
/// <summary> Loads all plugins from the given plugin .dll name. </summary> /// <summary> Loads all plugins from the given path. </summary>
public static bool Load(string name, bool startup) { public static bool Load(string path, bool startup) {
string path = IScripting.PluginPath(name);
try { try {
byte[] data = File.ReadAllBytes(path); byte[] data = File.ReadAllBytes(path);
Assembly lib = Assembly.Load(data); Assembly lib = Assembly.Load(data);
List<Plugin> plugins = IScripting.LoadTypes<Plugin>(lib); List<Plugin> plugins = IScripting.LoadTypes<Plugin>(lib);
@ -97,10 +95,8 @@ namespace MCGalaxy {
LoadCorePlugin(new NotesPlugin()); LoadCorePlugin(new NotesPlugin());
if (Directory.Exists("plugins")) { if (Directory.Exists("plugins")) {
foreach (string path in Directory.GetFiles("plugins", "*.dll")) { string[] files = Directory.GetFiles("plugins", "*.dll");
string name = Path.GetFileNameWithoutExtension(path); foreach (string path in files) { Load(path, true); }
Load(name, true);
}
} else { } else {
Directory.CreateDirectory("plugins"); Directory.CreateDirectory("plugins");
} }

View File

@ -17,8 +17,6 @@
*/ */
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading;
using MCGalaxy.Games;
using MCGalaxy.Network; using MCGalaxy.Network;
using MCGalaxy.Tasks; using MCGalaxy.Tasks;
@ -35,7 +33,6 @@ namespace MCGalaxy {
public static ServerConfig Config = new ServerConfig(); public static ServerConfig Config = new ServerConfig();
public static IRCBot IRC; public static IRCBot IRC;
public static Thread locationChecker;
public static DateTime StartTime; public static DateTime StartTime;
public static PlayerExtList AutoloadMaps; public static PlayerExtList AutoloadMaps;