Merge branch 'runelite' into question_mark_full_stop
# Conflicts: # runelite-client/src/main/java/com/openosrs/client/game/NPCStats.java # runelite-client/src/main/java/net/runelite/client/plugins/Plugin.java
This commit is contained in:
@@ -28,6 +28,7 @@ import com.google.inject.Binder;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Module;
|
||||
import org.pf4j.ExtensionPoint;
|
||||
import net.runelite.client.RuneLite;
|
||||
|
||||
public abstract class Plugin implements Module, ExtensionPoint
|
||||
{
|
||||
@@ -50,8 +51,20 @@ 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -164,20 +164,7 @@ 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();
|
||||
@@ -207,25 +194,7 @@ public class PluginManager
|
||||
plugins = getPlugins();
|
||||
}
|
||||
plugins.forEach(pl ->
|
||||
{
|
||||
//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());
|
||||
});
|
||||
injectors.add(pl.getInjector()));
|
||||
|
||||
List<Config> list = new ArrayList<>();
|
||||
for (Injector injector : injectors)
|
||||
|
||||
@@ -152,7 +152,7 @@ public class MenuEntrySwapperPlugin extends Plugin
|
||||
@Getter
|
||||
private boolean configuringShiftClick = false;
|
||||
|
||||
private final Multimap<String, Swap> swaps = LinkedHashMultimap.create();
|
||||
private static final Multimap<String, Swap> swaps = LinkedHashMultimap.create();
|
||||
private final ArrayListMultimap<String, Integer> optionIndexes = ArrayListMultimap.create();
|
||||
|
||||
@Provides
|
||||
@@ -361,7 +361,7 @@ public class MenuEntrySwapperPlugin extends Plugin
|
||||
swap("eat", "guzzle", config::swapRockCake);
|
||||
}
|
||||
|
||||
private void swap(String option, String swappedOption, Supplier<Boolean> enabled)
|
||||
public static void swap(String option, String swappedOption, Supplier<Boolean> enabled)
|
||||
{
|
||||
swap(option, alwaysTrue(), swappedOption, enabled);
|
||||
}
|
||||
@@ -371,7 +371,7 @@ public class MenuEntrySwapperPlugin extends Plugin
|
||||
swap(option, equalTo(target), swappedOption, enabled);
|
||||
}
|
||||
|
||||
private void swap(String option, Predicate<String> targetPredicate, String swappedOption, Supplier<Boolean> enabled)
|
||||
private static void swap(String option, Predicate<String> targetPredicate, String swappedOption, Supplier<Boolean> enabled)
|
||||
{
|
||||
swaps.put(option, new Swap(alwaysTrue(), targetPredicate, swappedOption, enabled, true));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user