mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-01-02 13:53:40 +01:00
feat: implement logic for third party repo
This commit is contained in:
parent
e8385d829b
commit
e6947e0cb8
2 changed files with 21 additions and 7 deletions
|
|
@ -132,6 +132,9 @@ namespace Dalamud.Plugin
|
||||||
} else if (this.dalamud.PluginRepository.State == PluginRepository.InitializationState.Fail) {
|
} else if (this.dalamud.PluginRepository.State == PluginRepository.InitializationState.Fail) {
|
||||||
ImGui.Text(Loc.Localize("InstallerDownloadFailed", "Download failed."));
|
ImGui.Text(Loc.Localize("InstallerDownloadFailed", "Download failed."));
|
||||||
}
|
}
|
||||||
|
else if (this.dalamud.PluginRepository.State == PluginRepository.InitializationState.FailThirdRepo) {
|
||||||
|
ImGui.Text(Loc.Localize("InstallerDownloadFailedThird", "One of your third party repos is unreachable or there is no internet connection."));
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
if (this.pluginListAvailable == null) {
|
if (this.pluginListAvailable == null) {
|
||||||
var hiddenPlugins = this.dalamud.PluginManager.Plugins.Where(
|
var hiddenPlugins = this.dalamud.PluginManager.Plugins.Where(
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.IO.Compression;
|
using System.IO.Compression;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
@ -16,7 +17,6 @@ namespace Dalamud.Plugin
|
||||||
private string PluginFunctionBaseUrl => "https://us-central1-xl-functions.cloudfunctions.net/download-plugin/?plugin={0}&isUpdate={1}&isTesting={2}";
|
private string PluginFunctionBaseUrl => "https://us-central1-xl-functions.cloudfunctions.net/download-plugin/?plugin={0}&isUpdate={1}&isTesting={2}";
|
||||||
private string PluginMasterUrl => "https://raw.githubusercontent.com/goatcorp/DalamudPlugins/master/pluginmaster.json";
|
private string PluginMasterUrl => "https://raw.githubusercontent.com/goatcorp/DalamudPlugins/master/pluginmaster.json";
|
||||||
|
|
||||||
|
|
||||||
private readonly Dalamud dalamud;
|
private readonly Dalamud dalamud;
|
||||||
private string pluginDirectory;
|
private string pluginDirectory;
|
||||||
public ReadOnlyCollection<PluginDefinition> PluginMaster;
|
public ReadOnlyCollection<PluginDefinition> PluginMaster;
|
||||||
|
|
@ -25,7 +25,8 @@ namespace Dalamud.Plugin
|
||||||
Unknown,
|
Unknown,
|
||||||
InProgress,
|
InProgress,
|
||||||
Success,
|
Success,
|
||||||
Fail
|
Fail,
|
||||||
|
FailThirdRepo
|
||||||
}
|
}
|
||||||
|
|
||||||
public InitializationState State { get; private set; }
|
public InitializationState State { get; private set; }
|
||||||
|
|
@ -43,20 +44,30 @@ namespace Dalamud.Plugin
|
||||||
|
|
||||||
State = InitializationState.InProgress;
|
State = InitializationState.InProgress;
|
||||||
|
|
||||||
|
var allPlugins = new List<PluginDefinition>();
|
||||||
|
|
||||||
|
var repos = this.dalamud.Configuration.ThirdRepoList.Where(x => x.IsEnabled).Select(x => x.Url)
|
||||||
|
.Prepend(PluginMasterUrl).ToArray();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
using var client = new WebClient();
|
using var client = new WebClient();
|
||||||
|
|
||||||
var data = client.DownloadString(PluginMasterUrl);
|
foreach (var repo in repos) {
|
||||||
|
Log.Information("[PLUGINR] Fetching repo: {0}", repo);
|
||||||
|
|
||||||
|
var data = client.DownloadString(repo);
|
||||||
|
|
||||||
var unsortedPluginMaster = JsonConvert.DeserializeObject<List<PluginDefinition>>(data);
|
var unsortedPluginMaster = JsonConvert.DeserializeObject<List<PluginDefinition>>(data);
|
||||||
unsortedPluginMaster.Sort((a, b) => a.Name.CompareTo(b.Name));
|
allPlugins.AddRange(unsortedPluginMaster);
|
||||||
this.PluginMaster = unsortedPluginMaster.AsReadOnly();
|
}
|
||||||
|
|
||||||
|
this.PluginMaster = allPlugins.AsReadOnly();
|
||||||
State = InitializationState.Success;
|
State = InitializationState.Success;
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
Log.Error(ex, "Could not download PluginMaster");
|
Log.Error(ex, "Could not download PluginMaster");
|
||||||
State = InitializationState.Fail;
|
|
||||||
|
State = repos.Length > 1 ? InitializationState.FailThirdRepo : InitializationState.Fail;
|
||||||
}
|
}
|
||||||
}).ContinueWith(t => {
|
}).ContinueWith(t => {
|
||||||
if (t.IsFaulted)
|
if (t.IsFaulted)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue