Merge pull request #2497 from xKylee/YEEEEEEEEEEEEEEEEEEEEET
project: remove legacy loader
This commit is contained in:
@@ -106,7 +106,6 @@ public class RuneLite
|
||||
public static final File RUNELITE_DIR = new File(System.getProperty("user.home"), ".runelite");
|
||||
public static final File CACHE_DIR = new File(RUNELITE_DIR, "cache");
|
||||
public static final File PROFILES_DIR = new File(RUNELITE_DIR, "profiles");
|
||||
public static final File PLUGIN_DIR = new File(RUNELITE_DIR, "plugins");
|
||||
public static final File EXTERNALPLUGIN_DIR = new File(RUNELITE_DIR, "externalmanager");
|
||||
public static final File SCREENSHOT_DIR = new File(RUNELITE_DIR, "screenshots");
|
||||
public static final File LOGS_DIR = new File(RUNELITE_DIR, "logs");
|
||||
@@ -401,9 +400,6 @@ public class RuneLite
|
||||
pluginManager.loadCorePlugins();
|
||||
externalPluginManager.loadPlugins();
|
||||
|
||||
// Load external plugins
|
||||
pluginManager.loadExternalPlugins();
|
||||
|
||||
RuneLiteSplashScreen.stage(.76, "Finalizing configuration");
|
||||
|
||||
// Plugins have provided their config, so set default config
|
||||
|
||||
@@ -252,45 +252,6 @@ public interface OpenOSRSConfig extends Config
|
||||
return new Color(244, 239, 211, 255);
|
||||
}
|
||||
|
||||
@Alpha
|
||||
@ConfigItem(
|
||||
position = 14,
|
||||
keyName = "externalColor",
|
||||
name = "External color",
|
||||
description = "Configure the color of external plugins",
|
||||
titleSection = "pluginsColorTitle",
|
||||
hidden = true,
|
||||
unhide = "enabledColors"
|
||||
)
|
||||
default Color externalColor()
|
||||
{
|
||||
return new Color(177, 156, 217, 255);
|
||||
}
|
||||
|
||||
@ConfigTitleSection(
|
||||
keyName = "externalPluginsTitle",
|
||||
name = "External",
|
||||
description = "",
|
||||
position = 15,
|
||||
titleSection = "pluginsTitle"
|
||||
)
|
||||
default Title externalPluginsTitle()
|
||||
{
|
||||
return new Title();
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "enablePlugins",
|
||||
name = "Enable loading of legacy external plugins",
|
||||
description = "Enable loading of legacy external plugins",
|
||||
position = 16,
|
||||
titleSection = "externalPluginsTitle"
|
||||
)
|
||||
default boolean enablePlugins()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ConfigTitleSection(
|
||||
keyName = "opacityTitle",
|
||||
name = "Opacity",
|
||||
|
||||
@@ -1,174 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins;
|
||||
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Key;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import javax.swing.SwingUtilities;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.client.RuneLite;
|
||||
import net.runelite.client.config.Config;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.config.OpenOSRSConfig;
|
||||
|
||||
@Singleton
|
||||
@Slf4j
|
||||
public class ExternalPluginLoader
|
||||
{
|
||||
private static final File BASE = RuneLite.PLUGIN_DIR;
|
||||
|
||||
private final OpenOSRSConfig OpenOSRSConfig;
|
||||
private final PluginManager pluginManager;
|
||||
|
||||
@Inject
|
||||
private ConfigManager configManager;
|
||||
|
||||
@Inject
|
||||
public ExternalPluginLoader(OpenOSRSConfig OpenOSRSConfig, PluginManager pluginManager)
|
||||
{
|
||||
this.OpenOSRSConfig = OpenOSRSConfig;
|
||||
this.pluginManager = pluginManager;
|
||||
|
||||
BASE.mkdirs();
|
||||
}
|
||||
|
||||
void scanAndLoad()
|
||||
{
|
||||
if (!OpenOSRSConfig.enablePlugins())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (File file : Objects.requireNonNull(BASE.listFiles()))
|
||||
{
|
||||
if (!file.getName().endsWith(".jar"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
log.info("Loading plugin from {}", file);
|
||||
load(file);
|
||||
}
|
||||
}
|
||||
|
||||
private void load(File pluginFile)
|
||||
{
|
||||
PluginClassLoader loader;
|
||||
try
|
||||
{
|
||||
loader = new PluginClassLoader(pluginFile, getClass().getClassLoader());
|
||||
}
|
||||
catch (MalformedURLException ex)
|
||||
{
|
||||
log.warn("Error loading plugin", ex);
|
||||
return;
|
||||
}
|
||||
|
||||
List<Plugin> loadedPlugins;
|
||||
try
|
||||
{
|
||||
loadedPlugins = pluginManager.scanAndInstantiate(loader, null, true);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
close(loader);
|
||||
log.warn("Error loading plugin", ex);
|
||||
return;
|
||||
}
|
||||
|
||||
if (loadedPlugins.isEmpty())
|
||||
{
|
||||
close(loader);
|
||||
log.warn("No plugin found in plugin {}", pluginFile);
|
||||
return;
|
||||
}
|
||||
|
||||
if (loadedPlugins.size() > 1)
|
||||
{
|
||||
close(loader);
|
||||
log.warn("You can not have more than one plugin per jar");
|
||||
return;
|
||||
}
|
||||
|
||||
Plugin plugin = loadedPlugins.get(0);
|
||||
|
||||
// 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, false);
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
SwingUtilities.invokeAndWait(() ->
|
||||
{
|
||||
try
|
||||
{
|
||||
pluginManager.startPlugin(plugin);
|
||||
}
|
||||
catch (PluginInstantiationException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
close(loader);
|
||||
log.warn("unable to start plugin", ex);
|
||||
return;
|
||||
}
|
||||
|
||||
// Plugin is now running
|
||||
pluginManager.add(plugin);
|
||||
}
|
||||
|
||||
private void close(URLClassLoader classLoader)
|
||||
{
|
||||
try
|
||||
{
|
||||
classLoader.close();
|
||||
}
|
||||
catch (IOException ex1)
|
||||
{
|
||||
log.warn(null, ex1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -651,12 +651,6 @@ public class ExternalPluginManager
|
||||
log.warn("Class {} has plugin descriptor, but is not a plugin", clazz);
|
||||
continue;
|
||||
}
|
||||
else if (pluginDescriptor.type() == PluginType.EXTERNAL)
|
||||
{
|
||||
log.error("Class {} is using the the new external plugin loader, it should not use PluginType.EXTERNAL",
|
||||
clazz);
|
||||
continue;
|
||||
}
|
||||
|
||||
List<Future<?>> curGroup = new ArrayList<>();
|
||||
curGroup.add(exec.submit(() ->
|
||||
|
||||
@@ -106,9 +106,6 @@ public class PluginManager
|
||||
private final Groups groups;
|
||||
private final File settingsFileInput;
|
||||
|
||||
@Inject
|
||||
ExternalPluginLoader externalPluginLoader;
|
||||
|
||||
@Setter
|
||||
boolean isOutdated;
|
||||
|
||||
@@ -289,12 +286,6 @@ public class PluginManager
|
||||
log.warn("Unable to reset plugin configuration", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public void loadExternalPlugins()
|
||||
{
|
||||
externalPluginLoader.scanAndLoad();
|
||||
}
|
||||
|
||||
public void loadCorePlugins() throws IOException
|
||||
{
|
||||
plugins.addAll(scanAndInstantiate(getClass().getClassLoader(), PLUGIN_PACKAGE, false));
|
||||
@@ -380,12 +371,6 @@ public class PluginManager
|
||||
continue;
|
||||
}
|
||||
|
||||
if (external && pluginDescriptor.type() != PluginType.EXTERNAL)
|
||||
{
|
||||
log.error("Class {} is using the external plugin loader but doesn't have PluginType.EXTERNAL", clazz);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!pluginDescriptor.loadWhenOutdated() && isOutdated)
|
||||
{
|
||||
continue;
|
||||
|
||||
@@ -13,7 +13,6 @@ public enum PluginType
|
||||
SKILLING("Skilling"),
|
||||
UTILITY("Utilities"),
|
||||
MISCELLANEOUS("Miscellaneous"),
|
||||
EXTERNAL("Legacy External"),
|
||||
IMPORTANT("System"),
|
||||
MINIGAME("Minigame"),
|
||||
GAMEMODE("Gamemode"),
|
||||
|
||||
@@ -104,7 +104,7 @@ public class PluginListPanel extends PluginPanel
|
||||
private static final String PINNED_PLUGINS_CONFIG_KEY = "pinnedPlugins";
|
||||
|
||||
private static final List<String> colorOptions = Arrays.asList("enabledColors", "pvmColor", "pvpColor", "skillingColor", "utilityColor", "minigameColor", "miscellaneousColor", "gamemodeColor");
|
||||
private static final List<PluginType> definedOrder = List.of(PluginType.IMPORTANT, PluginType.PVM, PluginType.SKILLING, PluginType.PVP, PluginType.UTILITY, PluginType.MINIGAME, PluginType.MISCELLANEOUS, PluginType.GAMEMODE, PluginType.EXTERNAL, PluginType.UNCATEGORIZED);
|
||||
private static final List<PluginType> definedOrder = List.of(PluginType.IMPORTANT, PluginType.PVM, PluginType.SKILLING, PluginType.PVP, PluginType.UTILITY, PluginType.MINIGAME, PluginType.MISCELLANEOUS, PluginType.GAMEMODE, PluginType.UNCATEGORIZED);
|
||||
private static final Comparator<PluginListItem> categoryComparator = Comparator.comparing(plugin -> definedOrder.indexOf(plugin.getPluginType()));
|
||||
|
||||
private final ConfigManager configManager;
|
||||
@@ -617,8 +617,6 @@ public class PluginListPanel extends PluginPanel
|
||||
|
||||
switch (pluginType)
|
||||
{
|
||||
case EXTERNAL:
|
||||
return openOSRSConfig.externalColor();
|
||||
case PVM:
|
||||
return openOSRSConfig.pvmColor();
|
||||
case PVP:
|
||||
|
||||
@@ -43,9 +43,9 @@ import javax.swing.JPanel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import net.runelite.api.Client;
|
||||
import static net.runelite.client.RuneLite.LOGS_DIR;
|
||||
import static net.runelite.client.RuneLite.PLUGINS_DIR;
|
||||
import static net.runelite.client.RuneLite.RUNELITE_DIR;
|
||||
import static net.runelite.client.RuneLite.SCREENSHOT_DIR;
|
||||
import static net.runelite.client.RuneLite.EXTERNALPLUGIN_DIR;
|
||||
import net.runelite.client.RuneLiteProperties;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.ui.ColorScheme;
|
||||
@@ -157,7 +157,7 @@ class InfoPanel extends PluginPanel
|
||||
actionsContainer.add(buildLinkPanel(IMPORT_ICON, "Launcher Download", "for the latest launcher", "https://github.com/open-osrs/launcher/releases"));
|
||||
actionsContainer.add(buildLinkPanel(FOLDER_ICON, "Open Runelite Directory", "for your .properties file", RUNELITE_DIR));
|
||||
actionsContainer.add(buildLinkPanel(FOLDER_ICON, "Open Logs Directory", "for bug reports", LOGS_DIR));
|
||||
actionsContainer.add(buildLinkPanel(FOLDER_ICON, "Open Plugins Directory", "for plugins", PLUGINS_DIR));
|
||||
actionsContainer.add(buildLinkPanel(FOLDER_ICON, "Open ExternalManager Directory", "to see your plugins", EXTERNALPLUGIN_DIR));
|
||||
actionsContainer.add(buildLinkPanel(FOLDER_ICON, "Open Screenshots Directory", "for your screenshots", SCREENSHOT_DIR));
|
||||
|
||||
JPanel pathPanel = new JPanel();
|
||||
|
||||
Reference in New Issue
Block a user