Merge pull request #2640 from open-osrs/upstream-3005

This commit is contained in:
Owain van Brakel
2020-05-30 07:18:33 +02:00
committed by GitHub
3 changed files with 58 additions and 20 deletions

View File

@@ -67,7 +67,9 @@ public enum AgilityShortcut
// Fossil Island Wyvern Cave // Fossil Island Wyvern Cave
STAIRS_31485, STAIRS_31485,
// Trollweiss Mountain Cave // Trollweiss Mountain Cave
ROCKY_HANDHOLDS, ROCKY_HANDHOLDS_19847), ROCKY_HANDHOLDS, ROCKY_HANDHOLDS_19847,
// Witchaven Dungeon
SHORTCUT),
BRIMHAVEN_DUNGEON_MEDIUM_PIPE_RETURN(1, "Pipe Squeeze", null, new WorldPoint(2698, 9491, 0), PIPE_21727), BRIMHAVEN_DUNGEON_MEDIUM_PIPE_RETURN(1, "Pipe Squeeze", null, new WorldPoint(2698, 9491, 0), PIPE_21727),
BRIMHAVEN_DUNGEON_PIPE_RETURN(1, "Pipe Squeeze", null, new WorldPoint(2655, 9573, 0), PIPE_21728), BRIMHAVEN_DUNGEON_PIPE_RETURN(1, "Pipe Squeeze", null, new WorldPoint(2655, 9573, 0), PIPE_21728),
BRIMHAVEN_DUNGEON_STEPPING_STONES_RETURN(1, "Pipe Squeeze", null, STEPPING_STONE_21739), BRIMHAVEN_DUNGEON_STEPPING_STONES_RETURN(1, "Pipe Squeeze", null, STEPPING_STONE_21739),

View File

@@ -560,27 +560,45 @@ public class ExternalPluginManager
try try
{ {
Module pluginModule = (Binder binder) -> Injector parent = RuneLite.getInjector();
if (deps.size() > 1)
{ {
binder.bind(clazz).toInstance(plugin); List<Module> modules = new ArrayList<>(deps.size());
binder.install(plugin);
for (Plugin p : deps) for (Plugin p : deps)
{ {
Module p2 = (Binder binder2) -> // Create a module for each dependency
Module module = (Binder binder) ->
{ {
binder2.bind((Class<Plugin>) p.getClass()).toInstance(p); binder.bind((Class<Plugin>) p.getClass()).toInstance(p);
binder2.install(p); binder.install(p);
}; };
binder.install(p2); modules.add(module);
} }
// Create a parent injector containing all of the dependencies
parent = parent.createChildInjector(modules);
}
else if (!deps.isEmpty())
{
// With only one dependency we can simply use its injector
parent = deps.get(0).injector;
}
// 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(clazz).toInstance(plugin);
binder.install(plugin);
}; };
Injector pluginInjector = RuneLite.getInjector().createChildInjector(pluginModule); Injector pluginInjector = parent.createChildInjector(pluginModule);
pluginInjector.injectMembers(plugin); pluginInjector.injectMembers(plugin);
plugin.injector = pluginInjector; plugin.injector = pluginInjector;
if (initConfig) if (initConfig)
{ {
for (Key<?> key : pluginInjector.getAllBindings().keySet()) for (Key<?> key : pluginInjector.getBindings().keySet())
{ {
Class<?> type = key.getTypeLiteral().getRawType(); Class<?> type = key.getTypeLiteral().getRawType();
if (Config.class.isAssignableFrom(type)) if (Config.class.isAssignableFrom(type))

View File

@@ -186,7 +186,7 @@ public class PluginManager
{ {
final Injector injector = plugin.getInjector(); final Injector injector = plugin.getInjector();
for (Key<?> key : injector.getAllBindings().keySet()) for (Key<?> key : injector.getBindings().keySet())
{ {
Class<?> type = key.getTypeLiteral().getRawType(); Class<?> type = key.getTypeLiteral().getRawType();
if (Config.class.isAssignableFrom(type)) if (Config.class.isAssignableFrom(type))
@@ -232,7 +232,7 @@ public class PluginManager
List<Config> list = new ArrayList<>(); List<Config> list = new ArrayList<>();
for (Injector injector : injectors) for (Injector injector : injectors)
{ {
for (Key<?> key : injector.getAllBindings().keySet()) for (Key<?> key : injector.getBindings().keySet())
{ {
Class<?> type = key.getTypeLiteral().getRawType(); Class<?> type = key.getTypeLiteral().getRawType();
if (Config.class.isAssignableFrom(type)) if (Config.class.isAssignableFrom(type))
@@ -589,21 +589,39 @@ public class PluginManager
try try
{ {
Module pluginModule = (Binder binder) -> Injector parent = RuneLite.getInjector();
if (deps.size() > 1)
{ {
binder.bind(clazz).toInstance(plugin); List<Module> modules = new ArrayList<>(deps.size());
binder.install(plugin);
for (Plugin p : deps) for (Plugin p : deps)
{ {
Module p2 = (Binder binder2) -> // Create a module for each dependency
Module module = (Binder binder) ->
{ {
binder2.bind((Class<Plugin>) p.getClass()).toInstance(p); binder.bind((Class<Plugin>) p.getClass()).toInstance(p);
binder2.install(p); binder.install(p);
}; };
binder.install(p2); modules.add(module);
} }
// Create a parent injector containing all of the dependencies
parent = parent.createChildInjector(modules);
}
else if (!deps.isEmpty())
{
// With only one dependency we can simply use its injector
parent = deps.get(0).injector;
}
// 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(clazz).toInstance(plugin);
binder.install(plugin);
}; };
Injector pluginInjector = RuneLite.getInjector().createChildInjector(pluginModule); Injector pluginInjector = parent.createChildInjector(pluginModule);
pluginInjector.injectMembers(plugin); pluginInjector.injectMembers(plugin);
plugin.injector = pluginInjector; plugin.injector = pluginInjector;
} }