touch up repository id display

This commit is contained in:
ThatGamerBlue
2020-03-01 06:43:03 +00:00
parent dc89055a3a
commit 569dff26ff
2 changed files with 20 additions and 12 deletions

View File

@@ -86,7 +86,6 @@ class ExternalPluginManager
private final ConfigManager configManager; private final ConfigManager configManager;
private final List<Plugin> plugins = new CopyOnWriteArrayList<>(); private final List<Plugin> plugins = new CopyOnWriteArrayList<>();
private final Map<String, String> pluginsMap = new HashMap<>(); private final Map<String, String> pluginsMap = new HashMap<>();
@Getter(AccessLevel.PUBLIC) @Getter(AccessLevel.PUBLIC)
private UpdateManager updateManager; private UpdateManager updateManager;
@@ -261,18 +260,13 @@ class ExternalPluginManager
public void startExternalUpdateManager() public void startExternalUpdateManager()
{ {
boolean loadedOld = false;
if (!tryLoadNewFormat()) if (!tryLoadNewFormat())
{ {
loadOldFormat(); loadOldFormat();
loadedOld = true;
} }
this.updateManager = new UpdateManager(this.externalPluginManager, repositories); this.updateManager = new UpdateManager(this.externalPluginManager, repositories);
if (loadedOld) saveConfig();
{
saveConfig();
}
} }
public boolean tryLoadNewFormat() public boolean tryLoadNewFormat()
@@ -284,19 +278,32 @@ class ExternalPluginManager
String[] split = keyval.split("\\|"); String[] split = keyval.split("\\|");
if (split.length != 2) if (split.length != 2)
{ {
log.error("failed to load new, split");
repositories.clear(); repositories.clear();
return false; return false;
} }
String id = split[0]; String id = split[0];
String url = split[1]; String url = split[1];
if (!url.endsWith("/"))
{
url = url.concat("/");
}
if (id.contains("https://raw.githubusercontent.com/"))
{
id = "gh:" + id.substring(id.indexOf("https://raw.githubusercontent.com/")).replace("/master", "")
.replace("https://raw.githubusercontent.com/", "");
if (id.endsWith("/"))
{
id = id.substring(0, id.lastIndexOf("/"));
}
}
repositories.add(new DefaultUpdateRepository(id, new URL(url))); repositories.add(new DefaultUpdateRepository(id, new URL(url)));
} }
} }
catch (ArrayIndexOutOfBoundsException | MalformedURLException e) catch (ArrayIndexOutOfBoundsException | MalformedURLException e)
{ {
log.error("failed to load new, exception", e);
repositories.clear(); repositories.clear();
return false; return false;
} }
@@ -397,7 +404,8 @@ class ExternalPluginManager
} }
else if (pluginDescriptor.type() == PluginType.EXTERNAL) else if (pluginDescriptor.type() == PluginType.EXTERNAL)
{ {
log.error("Class {} is using the the new external plugin loader, it should not use PluginType.EXTERNAL", clazz); log.error("Class {} is using the the new external plugin loader, it should not use PluginType.EXTERNAL",
clazz);
continue; continue;
} }

View File

@@ -58,8 +58,8 @@ public class RepositoryBox extends JPanel
setLayout(new BorderLayout()); setLayout(new BorderLayout());
setBackground(ColorScheme.DARKER_GRAY_COLOR); setBackground(ColorScheme.DARKER_GRAY_COLOR);
String name = updateRepository.getId().replace(updateRepository.getUrl().toString(), ""); String name = updateRepository.getId();
String urlString = updateRepository.getUrl().toString().replace("https://raw.githubusercontent.com/", "").replace("/master/", ""); String urlString = updateRepository.getUrl().toString();
JPanel titleWrapper = new JPanel(new BorderLayout()); JPanel titleWrapper = new JPanel(new BorderLayout());
titleWrapper.setBackground(ColorScheme.DARKER_GRAY_COLOR); titleWrapper.setBackground(ColorScheme.DARKER_GRAY_COLOR);