Readd @Subscribe, for unconditionally active subscriptions in plugins

This commit is contained in:
Lucwousin
2019-11-16 11:17:20 +01:00
parent b7bd7c5a08
commit 4fa3a73eb9
10 changed files with 147 additions and 27 deletions

View File

@@ -46,10 +46,13 @@ import java.util.List;
import java.util.Objects;
import java.util.Set;
import net.runelite.api.Client;
import net.runelite.api.events.Event;
import net.runelite.client.RuneLite;
import net.runelite.client.RuneLiteModule;
import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigItem;
import net.runelite.client.eventbus.EventBus;
import net.runelite.client.eventbus.Subscribe;
import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Rule;
@@ -108,7 +111,6 @@ public class PluginManagerTest
}
}
@SuppressWarnings("unchecked")
@Test
public void testLoadPlugins() throws Exception
{
@@ -190,4 +192,33 @@ public class PluginManagerTest
}
}
@Test
public void testEventbusAnnotations() throws PluginInstantiationException
{
EventBus eventbus = new EventBus();
PluginManager pluginManager = new PluginManager(true, eventbus, null, null, null, null)
{
@Override
public boolean isPluginEnabled(Plugin plugin)
{
return true;
}
};
class TestEvent implements Event {}
class TestPlugin extends Plugin
{
private boolean thisShouldBeTrue = false;
@Subscribe
private void doSomething(TestEvent event)
{
thisShouldBeTrue = true;
}
}
TestPlugin plugin = new TestPlugin();
pluginManager.startPlugin(plugin);
eventbus.post(TestEvent.class, new TestEvent());
assert plugin.thisShouldBeTrue;
}
}