net.runelite.client.config.Config Java Examples

The following examples show how to use net.runelite.client.config.Config. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PluginManager.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public List<Config> getPluginConfigProxies(Collection<Plugin> plugins)
{
	List<Injector> injectors = new ArrayList<>();
	if (plugins == null)
	{
		injectors.add(RuneLite.getInjector());
		plugins = getPlugins();
	}
	plugins.forEach(pl -> injectors.add(pl.getInjector()));

	List<Config> list = new ArrayList<>();
	for (Injector injector : injectors)
	{
		for (Key<?> key : injector.getBindings().keySet())
		{
			Class<?> type = key.getTypeLiteral().getRawType();
			if (Config.class.isAssignableFrom(type))
			{
				Config config = (Config) injector.getInstance(key);
				list.add(config);
			}
		}
	}

	return list;
}
 
Example #2
Source File: PluginListPanel.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
void rebuildPluginList()
{
	final List<String> pinnedPlugins = getPinnedPluginNames();

	// populate pluginList with all non-hidden plugins
	pluginList = Stream.concat(
		fakePlugins.stream(),
		pluginManager.getPlugins().stream()
			.filter(plugin -> !plugin.getClass().getAnnotation(PluginDescriptor.class).hidden())
			.map(plugin ->
			{
				PluginDescriptor descriptor = plugin.getClass().getAnnotation(PluginDescriptor.class);
				Config config = pluginManager.getPluginConfigProxy(plugin);
				ConfigDescriptor configDescriptor = config == null ? null : configManager.getConfigDescriptor(config);

				return new PluginConfigurationDescriptor(
					descriptor.name(),
					descriptor.description(),
					descriptor.tags(),
					plugin,
					config,
					configDescriptor);
			})
	).map(desc ->
	{
		PluginListItem listItem = new PluginListItem(this, desc);
		listItem.setPinned(pinnedPlugins.contains(desc.getName()));
		return listItem;
	}).collect(Collectors.toList());

	pluginList.sort(Comparator.comparing(p -> p.getPluginConfig().getName()));
	mainPanel.removeAll();
	refresh();
}
 
Example #3
Source File: PluginManagerTest.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Before
public void before() throws IOException
{
	OkHttpClient okHttpClient = mock(OkHttpClient.class);
	when(okHttpClient.newCall(any(Request.class)))
		.thenThrow(new RuntimeException("in plugin manager test"));

	Injector injector = Guice.createInjector(Modules
		.override(new RuneLiteModule(okHttpClient, () -> null, true, false,
			RuneLite.DEFAULT_SESSION_FILE,
			RuneLite.DEFAULT_CONFIG_FILE))
		.with(BoundFieldModule.of(this)));

	RuneLite.setInjector(injector);

	// Find plugins and configs we expect to have
	pluginClasses = new HashSet<>();
	configClasses = new HashSet<>();
	Set<ClassInfo> classes = ClassPath.from(getClass().getClassLoader()).getTopLevelClassesRecursive(PLUGIN_PACKAGE);
	for (ClassInfo classInfo : classes)
	{
		Class<?> clazz = classInfo.load();
		PluginDescriptor pluginDescriptor = clazz.getAnnotation(PluginDescriptor.class);
		if (pluginDescriptor != null)
		{
			pluginClasses.add(clazz);
			continue;
		}

		if (Config.class.isAssignableFrom(clazz))
		{
			configClasses.add(clazz);
		}
	}
}