if something is broken its probably this commit

This commit is contained in:
ThatGamerBlue
2021-02-13 21:33:06 +00:00
parent 93df4c9652
commit 3550d70e92
4 changed files with 50 additions and 19 deletions

View File

@@ -26,6 +26,7 @@ package net.runelite.api.events;
import lombok.Data;
import net.runelite.api.MenuAction;
import net.runelite.api.MenuEntry;
/**
* An event where a menu option has been clicked.
@@ -87,4 +88,14 @@ public class MenuOptionClicked
{
this.consumed = true;
}
public void setMenuEntry(MenuEntry entry)
{
this.setMenuOption(entry.getOption());
this.setMenuTarget(entry.getTarget());
this.setId(entry.getId());
this.setMenuAction(MenuAction.of(entry.getOpcode()));
this.setActionParam(entry.getActionParam());
this.setWidgetId(entry.getActionParam1());
}
}

View File

@@ -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();

View File

@@ -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)

View File

@@ -28,6 +28,10 @@ public interface RSTile extends Tile
@Override
GroundObject getGroundObject();
@Import("floorDecoration")
@Override
void setGroundObject(GroundObject object);
@Import("boundaryObject")
@Override
WallObject getWallObject();