if something is broken its probably this commit
This commit is contained in:
@@ -27,11 +27,13 @@ package net.runelite.client.plugins;
|
||||
import com.google.inject.Binder;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Module;
|
||||
import lombok.Getter;
|
||||
import org.pf4j.ExtensionPoint;
|
||||
import net.runelite.client.RuneLite;
|
||||
|
||||
public abstract class Plugin implements Module, ExtensionPoint
|
||||
{
|
||||
@Getter
|
||||
protected Injector injector;
|
||||
|
||||
@Override
|
||||
@@ -51,23 +53,6 @@ public abstract class Plugin implements Module, ExtensionPoint
|
||||
{
|
||||
}
|
||||
|
||||
// This should never be null when we are using it
|
||||
public final Injector getInjector()
|
||||
{
|
||||
if (injector == null)
|
||||
{
|
||||
Module pluginModule = (Binder binder) ->
|
||||
{
|
||||
binder.bind((Class<Plugin>) this.getClass()).toInstance(this);
|
||||
binder.install(this);
|
||||
};
|
||||
Injector pluginInjector = RuneLite.getInjector().createChildInjector(pluginModule);
|
||||
pluginInjector.injectMembers(this);
|
||||
injector = pluginInjector;
|
||||
}
|
||||
return injector;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return getClass().getAnnotation(PluginDescriptor.class).name();
|
||||
|
||||
@@ -164,7 +164,20 @@ public class PluginManager
|
||||
try
|
||||
{
|
||||
Injector injector = plugin.getInjector();
|
||||
|
||||
if (injector == null)
|
||||
{
|
||||
// Create injector for the module
|
||||
Module pluginModule = (Binder binder) ->
|
||||
{
|
||||
// Since the plugin itself is a module, it won't bind itself, so we'll bind it here
|
||||
binder.bind((Class<Plugin>) plugin.getClass()).toInstance(plugin);
|
||||
binder.install(plugin);
|
||||
};
|
||||
Injector pluginInjector = RuneLite.getInjector().createChildInjector(pluginModule);
|
||||
pluginInjector.injectMembers(plugin);
|
||||
plugin.injector = pluginInjector;
|
||||
injector = pluginInjector;
|
||||
}
|
||||
for (Key<?> key : injector.getBindings().keySet())
|
||||
{
|
||||
Class<?> type = key.getTypeLiteral().getRawType();
|
||||
@@ -194,7 +207,25 @@ public class PluginManager
|
||||
plugins = getPlugins();
|
||||
}
|
||||
plugins.forEach(pl ->
|
||||
injectors.add(pl.getInjector()));
|
||||
{
|
||||
//TODO: Not sure why this is necessary but it is. The Injector isn't null when its handed off from our ExternalPluginManager.
|
||||
// Hopefully we can figure out the root cause of the underlying issue.
|
||||
if (pl.injector == null)
|
||||
{
|
||||
// Create injector for the module
|
||||
Module pluginModule = (Binder binder) ->
|
||||
{
|
||||
// Since the plugin itself is a module, it won't bind itself, so we'll bind it here
|
||||
binder.bind((Class<Plugin>) pl.getClass()).toInstance(pl);
|
||||
binder.install(pl);
|
||||
};
|
||||
Injector pluginInjector = RuneLite.getInjector().createChildInjector(pluginModule);
|
||||
pluginInjector.injectMembers(pl);
|
||||
pl.injector = pluginInjector;
|
||||
}
|
||||
|
||||
injectors.add(pl.getInjector());
|
||||
});
|
||||
|
||||
List<Config> list = new ArrayList<>();
|
||||
for (Injector injector : injectors)
|
||||
|
||||
Reference in New Issue
Block a user