Merge pull request #252 from tylerthardy/dynamicFix
Fix default config for dynamic plugins
This commit is contained in:
@@ -352,7 +352,7 @@ public class ConfigManager
|
|||||||
* Initialize the configuration from the default settings
|
* Initialize the configuration from the default settings
|
||||||
* @param proxy
|
* @param proxy
|
||||||
*/
|
*/
|
||||||
private void setDefaultConfiguration(Object proxy)
|
public void setDefaultConfiguration(Object proxy)
|
||||||
{
|
{
|
||||||
Class<?> clazz = proxy.getClass().getInterfaces()[0];
|
Class<?> clazz = proxy.getClass().getInterfaces()[0];
|
||||||
ConfigGroup group = clazz.getAnnotation(ConfigGroup.class);
|
ConfigGroup group = clazz.getAnnotation(ConfigGroup.class);
|
||||||
|
|||||||
@@ -24,6 +24,8 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.plugins;
|
package net.runelite.client.plugins;
|
||||||
|
|
||||||
|
import com.google.inject.Injector;
|
||||||
|
import com.google.inject.Key;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
@@ -41,6 +43,8 @@ import javax.inject.Inject;
|
|||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.client.RuneLite;
|
import net.runelite.client.RuneLite;
|
||||||
|
import net.runelite.client.config.Config;
|
||||||
|
import net.runelite.client.config.ConfigManager;
|
||||||
import net.runelite.client.config.RuneliteConfig;
|
import net.runelite.client.config.RuneliteConfig;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@@ -54,6 +58,9 @@ public class PluginWatcher extends Thread
|
|||||||
private final WatchService watchService;
|
private final WatchService watchService;
|
||||||
private final WatchKey watchKey;
|
private final WatchKey watchKey;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private ConfigManager configManager;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public PluginWatcher(RuneliteConfig runeliteConfig, PluginManager pluginManager) throws IOException
|
public PluginWatcher(RuneliteConfig runeliteConfig, PluginManager pluginManager) throws IOException
|
||||||
{
|
{
|
||||||
@@ -208,6 +215,18 @@ public class PluginWatcher extends Thread
|
|||||||
plugin.file = pluginFile;
|
plugin.file = pluginFile;
|
||||||
plugin.loader = loader;
|
plugin.loader = loader;
|
||||||
|
|
||||||
|
// Initialize default configuration
|
||||||
|
Injector injector = plugin.getInjector();
|
||||||
|
for (Key<?> key : injector.getAllBindings().keySet())
|
||||||
|
{
|
||||||
|
Class<?> type = key.getTypeLiteral().getRawType();
|
||||||
|
if (Config.class.isAssignableFrom(type))
|
||||||
|
{
|
||||||
|
Config config = (Config) injector.getInstance(key);
|
||||||
|
configManager.setDefaultConfiguration(config);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pluginManager.startPlugin(plugin);
|
pluginManager.startPlugin(plugin);
|
||||||
|
|||||||
Reference in New Issue
Block a user