Send launch properties around as bound constants
Instead of exposing static variable provide launch properties to dependant classes as bound constants in RuneLiteModule. Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
@@ -53,7 +53,6 @@ import net.runelite.client.game.ClanManager;
|
||||
import net.runelite.client.game.ItemManager;
|
||||
import net.runelite.client.menus.MenuManager;
|
||||
import net.runelite.client.plugins.PluginManager;
|
||||
import net.runelite.client.rs.ClientLoader;
|
||||
import net.runelite.client.rs.ClientUpdateCheckMode;
|
||||
import net.runelite.client.ui.ClientUI;
|
||||
import net.runelite.client.ui.DrawManager;
|
||||
@@ -80,9 +79,6 @@ public class RuneLite
|
||||
@Getter
|
||||
private static Injector injector;
|
||||
|
||||
@Getter
|
||||
private static OptionSet options;
|
||||
|
||||
@Inject
|
||||
private PluginManager pluginManager;
|
||||
|
||||
@@ -174,15 +170,17 @@ public class RuneLite
|
||||
});
|
||||
|
||||
parser.accepts("help", "Show this text").forHelp();
|
||||
options = parser.parse(args);
|
||||
OptionSet options = parser.parse(args);
|
||||
|
||||
if (getOptions().has("help"))
|
||||
if (options.has("help"))
|
||||
{
|
||||
parser.printHelpOn(System.out);
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
if (RuneLite.getOptions().has("developer-mode") && RuneLiteProperties.getLauncherVersion() == null)
|
||||
final boolean developerMode = options.has("developer-mode");
|
||||
|
||||
if (developerMode && RuneLiteProperties.getLauncherVersion() == null)
|
||||
{
|
||||
boolean assertions = false;
|
||||
assert assertions = true;
|
||||
@@ -212,8 +210,10 @@ public class RuneLite
|
||||
}
|
||||
});
|
||||
|
||||
injector = Guice.createInjector(new RuneLiteModule());
|
||||
injector.getInstance(ClientLoader.class).setUpdateCheckMode(getOptions().valueOf(updateMode));
|
||||
injector = Guice.createInjector(new RuneLiteModule(
|
||||
options.valueOf(updateMode),
|
||||
developerMode));
|
||||
|
||||
injector.getInstance(RuneLite.class).start();
|
||||
}
|
||||
|
||||
@@ -298,10 +298,4 @@ public class RuneLite
|
||||
{
|
||||
RuneLite.injector = injector;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public static void setOptions(OptionSet options)
|
||||
{
|
||||
RuneLite.options = options;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ import net.runelite.client.config.RuneLiteConfig;
|
||||
import net.runelite.client.game.ItemManager;
|
||||
import net.runelite.client.menus.MenuManager;
|
||||
import net.runelite.client.plugins.PluginManager;
|
||||
import net.runelite.client.rs.ClientUpdateCheckMode;
|
||||
import net.runelite.client.rs.ClientLoader;
|
||||
import net.runelite.client.task.Scheduler;
|
||||
import net.runelite.client.util.DeferredEventBus;
|
||||
@@ -58,9 +59,20 @@ import okhttp3.OkHttpClient;
|
||||
@Slf4j
|
||||
public class RuneLiteModule extends AbstractModule
|
||||
{
|
||||
private final ClientUpdateCheckMode updateCheckMode;
|
||||
private final boolean developerMode;
|
||||
|
||||
public RuneLiteModule(final ClientUpdateCheckMode updateCheckMode, final boolean developerMode)
|
||||
{
|
||||
this.updateCheckMode = updateCheckMode;
|
||||
this.developerMode = developerMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure()
|
||||
{
|
||||
bindConstant().annotatedWith(Names.named("updateCheckMode")).to(updateCheckMode);
|
||||
bindConstant().annotatedWith(Names.named("developerMode")).to(developerMode);
|
||||
bind(ScheduledExecutorService.class).toInstance(Executors.newSingleThreadScheduledExecutor());
|
||||
bind(OkHttpClient.class).toInstance(RuneLiteAPI.CLIENT);
|
||||
bind(QueryRunner.class);
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
*/
|
||||
package net.runelite.client.plugins;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.eventbus.EventBus;
|
||||
@@ -36,7 +37,6 @@ import com.google.common.reflect.ClassPath;
|
||||
import com.google.common.reflect.ClassPath.ClassInfo;
|
||||
import com.google.inject.Binder;
|
||||
import com.google.inject.CreationException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Key;
|
||||
import com.google.inject.Module;
|
||||
@@ -52,6 +52,8 @@ import java.util.Set;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
import javax.swing.SwingUtilities;
|
||||
import lombok.Setter;
|
||||
@@ -78,29 +80,38 @@ public class PluginManager
|
||||
*/
|
||||
private static final String PLUGIN_PACKAGE = "net.runelite.client.plugins";
|
||||
|
||||
@Inject
|
||||
EventBus eventBus;
|
||||
|
||||
@Inject
|
||||
Scheduler scheduler;
|
||||
|
||||
@Inject
|
||||
ConfigManager configManager;
|
||||
|
||||
@Inject
|
||||
ScheduledExecutorService executor;
|
||||
|
||||
@Inject
|
||||
SceneTileManager sceneTileManager;
|
||||
|
||||
@Setter
|
||||
boolean isOutdated;
|
||||
|
||||
private final boolean developerMode;
|
||||
private final EventBus eventBus;
|
||||
private final Scheduler scheduler;
|
||||
private final ConfigManager configManager;
|
||||
private final ScheduledExecutorService executor;
|
||||
private final SceneTileManager sceneTileManager;
|
||||
private final List<Plugin> plugins = new CopyOnWriteArrayList<>();
|
||||
private final List<Plugin> activePlugins = new CopyOnWriteArrayList<>();
|
||||
private final String runeliteGroupName = RuneLiteConfig.class
|
||||
.getAnnotation(ConfigGroup.class).value();
|
||||
|
||||
@Setter
|
||||
boolean isOutdated;
|
||||
|
||||
@Inject
|
||||
@VisibleForTesting
|
||||
PluginManager(
|
||||
@Named("developerMode") final boolean developerMode,
|
||||
final EventBus eventBus,
|
||||
final Scheduler scheduler,
|
||||
final ConfigManager configManager,
|
||||
final ScheduledExecutorService executor,
|
||||
final SceneTileManager sceneTileManager)
|
||||
{
|
||||
this.developerMode = developerMode;
|
||||
this.eventBus = eventBus;
|
||||
this.scheduler = scheduler;
|
||||
this.configManager = configManager;
|
||||
this.executor = executor;
|
||||
this.sceneTileManager = sceneTileManager;
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onSessionOpen(SessionOpen event)
|
||||
{
|
||||
@@ -204,8 +215,6 @@ public class PluginManager
|
||||
|
||||
List<Plugin> scanAndInstantiate(ClassLoader classLoader, String packageName) throws IOException
|
||||
{
|
||||
boolean developerPlugins = RuneLite.getOptions().has("developer-mode");
|
||||
|
||||
MutableGraph<Class<? extends Plugin>> graph = GraphBuilder
|
||||
.directed()
|
||||
.build();
|
||||
@@ -242,7 +251,7 @@ public class PluginManager
|
||||
continue;
|
||||
}
|
||||
|
||||
if (pluginDescriptor.developerPlugin() && !developerPlugins)
|
||||
if (pluginDescriptor.developerPlugin() && !developerMode)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -30,8 +30,8 @@ import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.http.api.updatecheck.UpdateCheckClient;
|
||||
|
||||
@@ -41,13 +41,14 @@ public class ClientLoader
|
||||
{
|
||||
private final UpdateCheckClient updateCheckClient = new UpdateCheckClient();
|
||||
private final ClientConfigLoader clientConfigLoader;
|
||||
|
||||
@Setter
|
||||
private ClientUpdateCheckMode updateCheckMode = ClientUpdateCheckMode.AUTO;
|
||||
private final ClientUpdateCheckMode updateCheckMode;
|
||||
|
||||
@Inject
|
||||
private ClientLoader(final ClientConfigLoader clientConfigLoader)
|
||||
private ClientLoader(
|
||||
@Named("updateCheckMode") final ClientUpdateCheckMode updateCheckMode,
|
||||
final ClientConfigLoader clientConfigLoader)
|
||||
{
|
||||
this.updateCheckMode = updateCheckMode;
|
||||
this.clientConfigLoader = clientConfigLoader;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user