Skip to content

Commit

Permalink
Merge pull request runelite#2331 from Owain94/externalserrors
Browse files Browse the repository at this point in the history
externals: Fix some issues
  • Loading branch information
Owain94 authored Feb 11, 2020
2 parents d884e90 + 7742e61 commit 5b1ecd4
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ private void start() throws Exception
pluginManager.loadCorePlugins();

// Load external plugins
externalPluginManager.startExternalUpdateManager();
externalPluginManager.startExternalPluginManager();

RuneLiteSplashScreen.stage(.75, "Finalizing configuration");
Expand All @@ -380,7 +381,6 @@ private void start() throws Exception
// to main settings
pluginManager.loadDefaultPluginConfiguration();

externalPluginManager.startExternalUpdateManager();

RuneLiteSplashScreen.stage(.77, "Updating external plugins");
externalPluginManager.update();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.lang.reflect.InvocationTargetException;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
Expand Down Expand Up @@ -41,10 +42,12 @@
import org.pf4j.JarPluginLoader;
import org.pf4j.JarPluginRepository;
import org.pf4j.ManifestPluginDescriptorFinder;
import org.pf4j.PluginAlreadyLoadedException;
import org.pf4j.PluginDependency;
import org.pf4j.PluginDescriptorFinder;
import org.pf4j.PluginLoader;
import org.pf4j.PluginRepository;
import org.pf4j.PluginRuntimeException;
import org.pf4j.PluginWrapper;
import org.pf4j.RuntimeMode;
import org.pf4j.update.DefaultUpdateRepository;
Expand Down Expand Up @@ -112,6 +115,55 @@ public RuntimeMode getRuntimeMode()
{
return debug ? RuntimeMode.DEVELOPMENT : RuntimeMode.DEPLOYMENT;
}

@Override
public void loadPlugins()
{
if (Files.notExists(pluginsRoot) || !Files.isDirectory(pluginsRoot))
{
log.warn("No '{}' root", pluginsRoot);
return;
}

List<Path> pluginPaths = pluginRepository.getPluginPaths();

if (pluginPaths.isEmpty())
{
log.info("No plugins");
return;
}

log.debug("Found {} possible plugins: {}", pluginPaths.size(), pluginPaths);

for (Path pluginPath : pluginPaths)
{
try
{
loadPluginFromPath(pluginPath);
}
catch (PluginRuntimeException e)
{
if (!(e instanceof PluginAlreadyLoadedException))
{
log.error(e.getMessage(), e);
}
}
}

try
{
resolvePlugins();
}
catch (PluginRuntimeException e)
{
if (e instanceof DependencyResolver.DependenciesNotFoundException)
{
throw e;
}

log.error(e.getMessage(), e);
}
}
};
this.externalPluginManager.setSystemVersion(SYSTEM_VERSION);
}
Expand Down Expand Up @@ -145,7 +197,30 @@ public static <T> Predicate<T> not(Predicate<T> t)

public void startExternalPluginManager()
{
this.externalPluginManager.loadPlugins();
try
{
this.externalPluginManager.loadPlugins();
}
catch (Exception ex)
{
if (ex instanceof DependencyResolver.DependenciesNotFoundException)
{
List<String> deps = ((DependencyResolver.DependenciesNotFoundException) ex).getDependencies();

log.error("The following dependencies are missing: {}", deps);

for (String dep : deps)
{
install(dep);
}

startExternalPluginManager();
}

log.error("{}", ex.getMessage());
}

log.info(String.valueOf(externalPluginManager.getResolvedPlugins()));
}

public void startExternalUpdateManager()
Expand Down Expand Up @@ -482,11 +557,18 @@ public void update()
{
PluginInfo.PluginRelease lastRelease = updateManager.getLastPluginRelease(plugin.id);
String lastVersion = lastRelease.version;
boolean updated = updateManager.updatePlugin(plugin.id, lastVersion);
try
{
boolean updated = updateManager.updatePlugin(plugin.id, lastVersion);

if (!updated)
if (!updated)
{
log.warn("Cannot update plugin '{}'", plugin.id);
}
}
catch (PluginRuntimeException ex)
{
log.warn("Cannot update plugin '{}'", plugin.id);
log.warn("Cannot update plugin '{}', the user probably has another client open", plugin.id);
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions runelite-client/src/main/resources/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,6 @@
<appender-ref ref="STDOUT"/>
<appender-ref ref="FILE"/>
</root>

<logger name="org.pf4j.AbstractPluginManager" level="OFF"/>
</configuration>

0 comments on commit 5b1ecd4

Please sign in to comment.