mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-26 18:22:54 +08:00
load all classes from plugin
This commit is contained in:
parent
c4bdcc387c
commit
9fb5b69ddd
@ -13,6 +13,8 @@ import java.lang.reflect.Method;
|
|||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLClassLoader;
|
import java.net.URLClassLoader;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.jar.JarEntry;
|
||||||
|
import java.util.jar.JarFile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages the server's plugins & the event system.
|
* Manages the server's plugins & the event system.
|
||||||
@ -60,6 +62,15 @@ public final class PluginManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JarFile jarFile = new JarFile(plugin);
|
||||||
|
Enumeration<JarEntry> entries = jarFile.entries();
|
||||||
|
while(entries.hasMoreElements()) {
|
||||||
|
JarEntry entry = entries.nextElement();
|
||||||
|
if(entry.isDirectory() || !entry.getName().endsWith(".class")) continue;
|
||||||
|
String className = entry.getName().replace(".class", "").replace("/", ".");
|
||||||
|
Class<?> clazz = loader.loadClass(className);
|
||||||
|
}
|
||||||
|
|
||||||
Class<?> pluginClass = loader.loadClass(pluginConfig.mainClass);
|
Class<?> pluginClass = loader.loadClass(pluginConfig.mainClass);
|
||||||
Plugin pluginInstance = (Plugin) pluginClass.getDeclaredConstructor().newInstance();
|
Plugin pluginInstance = (Plugin) pluginClass.getDeclaredConstructor().newInstance();
|
||||||
this.loadPlugin(pluginInstance, PluginIdentifier.fromPluginConfig(pluginConfig));
|
this.loadPlugin(pluginInstance, PluginIdentifier.fromPluginConfig(pluginConfig));
|
||||||
|
Loading…
Reference in New Issue
Block a user