mirror of https://github.com/LOOHP/Limbo.git
Fixed Access Control, Fixed PluginManager null during onLoad for LimboPlugins
This commit is contained in:
parent
e8f4e86b16
commit
bae75e0d0a
|
|
@ -9,6 +9,8 @@ import java.io.FileReader;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URL;
|
||||
import java.nio.channels.Channels;
|
||||
import java.nio.channels.ReadableByteChannel;
|
||||
|
|
@ -285,7 +287,15 @@ public class Limbo {
|
|||
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
|
||||
fos.close();
|
||||
|
||||
pluginManager = new PluginManager(pluginFolder);
|
||||
pluginManager = new PluginManager(pluginFolder);
|
||||
try {
|
||||
Method loadPluginsMethod = PluginManager.class.getDeclaredMethod("loadPlugins");
|
||||
loadPluginsMethod.setAccessible(true);
|
||||
loadPluginsMethod.invoke(pluginManager);
|
||||
loadPluginsMethod.setAccessible(false);
|
||||
} catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
for (LimboPlugin plugin : Limbo.getInstance().getPluginManager().getPlugins()) {
|
||||
console.sendMessage("Enabling plugin " + plugin.getName() + " " + plugin.getInfo().getVersion());
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ public class LimboPlugin {
|
|||
private File dataFolder;
|
||||
private PluginInfo info;
|
||||
|
||||
public final void setInfo(FileConfiguration file) {
|
||||
protected final void setInfo(FileConfiguration file) {
|
||||
info = new PluginInfo(file);
|
||||
name = info.getName();
|
||||
dataFolder = new File(Limbo.getInstance().getPluginFolder(), name);
|
||||
|
|
@ -29,19 +29,19 @@ public class LimboPlugin {
|
|||
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
public final String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public File getDataFolder() {
|
||||
public final File getDataFolder() {
|
||||
return new File(dataFolder.getAbsolutePath());
|
||||
}
|
||||
|
||||
public PluginInfo getInfo() {
|
||||
public final PluginInfo getInfo() {
|
||||
return info;
|
||||
}
|
||||
|
||||
public Limbo getServer() {
|
||||
public final Limbo getServer() {
|
||||
return Limbo.getInstance();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,9 +27,10 @@ public class PluginManager {
|
|||
public PluginManager(File pluginFolder) {
|
||||
this.pluginFolder = pluginFolder;
|
||||
this.executors = new ArrayList<>();
|
||||
|
||||
this.plugins = new LinkedHashMap<>();
|
||||
|
||||
}
|
||||
|
||||
protected void loadPlugins() {
|
||||
for (File file : pluginFolder.listFiles()) {
|
||||
if (file.isFile() && file.getName().endsWith(".jar")) {
|
||||
boolean found = false;
|
||||
|
|
@ -54,12 +55,12 @@ public class PluginManager {
|
|||
}
|
||||
|
||||
URLClassLoader url = new URLClassLoader(new URL[] {file.toURI().toURL()});
|
||||
Class<?> plugin = url.loadClass(main);
|
||||
LimboPlugin clazz = (LimboPlugin) plugin.getDeclaredConstructor().newInstance();
|
||||
clazz.setInfo(pluginYaml);
|
||||
plugins.put(clazz.getName(), clazz);
|
||||
clazz.onLoad();
|
||||
Limbo.getInstance().getConsole().sendMessage("Loading plugin " + file.getName() + " " + clazz.getInfo().getVersion() + " by " + clazz.getInfo().getAuthor());
|
||||
Class<?> clazz = url.loadClass(main);
|
||||
LimboPlugin plugin = (LimboPlugin) clazz.getDeclaredConstructor().newInstance();
|
||||
plugin.setInfo(pluginYaml);
|
||||
plugins.put(plugin.getName(), plugin);
|
||||
plugin.onLoad();
|
||||
Limbo.getInstance().getConsole().sendMessage("Loading plugin " + file.getName() + " " + plugin.getInfo().getVersion() + " by " + plugin.getInfo().getAuthor());
|
||||
url.close();
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue