diff --git a/Dalamud/Plugin/PluginDefinition.cs b/Dalamud/Plugin/PluginDefinition.cs index 86b9149e7..60dae3864 100644 --- a/Dalamud/Plugin/PluginDefinition.cs +++ b/Dalamud/Plugin/PluginDefinition.cs @@ -57,5 +57,10 @@ namespace Dalamud.Plugin /// The API level of this plugin. For the current API level, please see for the currently used API level. /// public int DalamudApiLevel { get; set; } + + /// + /// The number of downloads this plugin has. + /// + public long DownloadCount { get; set; } } } diff --git a/Dalamud/Plugin/PluginInstallerWindow.cs b/Dalamud/Plugin/PluginInstallerWindow.cs index 6f4dfcf8b..e7d67f7e4 100644 --- a/Dalamud/Plugin/PluginInstallerWindow.cs +++ b/Dalamud/Plugin/PluginInstallerWindow.cs @@ -120,7 +120,7 @@ namespace Dalamud.Plugin ImGui.Text(pluginDefinition.Name); ImGui.SameLine(); - ImGui.TextColored(new Vector4(0.5f, 0.5f, 0.5f, 1.0f), $" by {pluginDefinition.Author}"); + ImGui.TextColored(new Vector4(0.5f, 0.5f, 0.5f, 1.0f), $" by {pluginDefinition.Author}, {pluginDefinition.DownloadCount} downloads"); ImGui.Text(pluginDefinition.Description); diff --git a/Dalamud/Plugin/PluginRepository.cs b/Dalamud/Plugin/PluginRepository.cs index db4ff0489..502787eb5 100644 --- a/Dalamud/Plugin/PluginRepository.cs +++ b/Dalamud/Plugin/PluginRepository.cs @@ -14,7 +14,10 @@ namespace Dalamud.Plugin { internal class PluginRepository { - private string PluginRepoBaseUrl => "https://raw.githubusercontent.com/goatcorp/DalamudPlugins/" + (this.dalamud.Configuration.DoPluginTest ? "testing/" : "master/"); + private string PluginRepoBaseUrl => "https://raw.githubusercontent.com/goatcorp/DalamudPlugins/testing/plugins/{0}/latest.zip"; + private string PluginFunctionBaseUrl => "https://us-central1-xl-functions.cloudfunctions.net/download-plugin/?plugin={0}"; + private string PluginMasterUrl => "https://raw.githubusercontent.com/goatcorp/DalamudPlugins/" + (this.dalamud.Configuration.DoPluginTest ? "testing/" : "master/") + "pluginmaster.json"; + private readonly Dalamud dalamud; private string pluginDirectory; @@ -46,7 +49,7 @@ namespace Dalamud.Plugin { using var client = new WebClient(); - var data = client.DownloadString(PluginRepoBaseUrl + "pluginmaster.json"); + var data = client.DownloadString(PluginMasterUrl); this.PluginMaster = JsonConvert.DeserializeObject>(data); @@ -92,9 +95,14 @@ namespace Dalamud.Plugin } var path = Path.GetTempFileName(); - Log.Information("Downloading plugin to {0}", path); + using var client = new WebClient(); - client.DownloadFile(PluginRepoBaseUrl + $"/plugins/{definition.InternalName}/latest.zip", path); + + var url = this.dalamud.Configuration.DoPluginTest ? PluginRepoBaseUrl : PluginFunctionBaseUrl; + url = string.Format(url, definition.InternalName); + Log.Information("Downloading plugin to {0} from {1}", path, url); + + client.DownloadFile(url, path); Log.Information("Extracting to {0}", outputDir);