diff --git a/CHANGELOG.md b/CHANGELOG.md index ca33e66..953948a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,18 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +## [1.2.2] - 2023-05-30 +### Added +- Add version option to include snapshots during load, by default this is false +- Add indicator to show that the current version is a snapshot / preview / experimental / beta / alpha build +- Add IsSnapshot test cases + +### Changed +- Restructure and simplify API directories + +### Removed +- Separation of Snapshot ans Standard versions for Mojang, Fabric and Pocketmine plugin, this is handled now via the IsSnapshot indicator on IVersion + ## [1.2.1] - 2023-05-29 ### Fixed diff --git a/MinecraftJars.Core/Versions/IVersion.cs b/MinecraftJars.Core/Versions/IVersion.cs index 4300a4e..9f32121 100644 --- a/MinecraftJars.Core/Versions/IVersion.cs +++ b/MinecraftJars.Core/Versions/IVersion.cs @@ -15,6 +15,11 @@ public interface IVersion /// string Version { get; } + /// + /// Indicates whether this version experimental + /// + bool IsSnapShot { get; } + /// /// Indicates TRUE in case the plugin needs to build the JAR file instead of providing download information /// diff --git a/MinecraftJars.Core/Versions/VersionOptions.cs b/MinecraftJars.Core/Versions/VersionOptions.cs index c0a7c65..7bf938a 100644 --- a/MinecraftJars.Core/Versions/VersionOptions.cs +++ b/MinecraftJars.Core/Versions/VersionOptions.cs @@ -9,6 +9,11 @@ public class VersionOptions /// public string? Version { get; set; } + /// + /// Indicates to return snapshot / experimental / preview / beta / alpha builds as well + /// + public bool IncludeSnapshotBuilds { get; set; } + /// /// Limit the amount of records returned by the plugin API. Useful if only /// e.g. the last x Versions are required. diff --git a/MinecraftJars.Plugin/MinecraftJars.Plugin.Fabric/FabricProjectFactory.cs b/MinecraftJars.Plugin/MinecraftJars.Plugin.Fabric/FabricProjectFactory.cs index 8d1fb67..b83eede 100644 --- a/MinecraftJars.Plugin/MinecraftJars.Plugin.Fabric/FabricProjectFactory.cs +++ b/MinecraftJars.Plugin/MinecraftJars.Plugin.Fabric/FabricProjectFactory.cs @@ -6,7 +6,6 @@ namespace MinecraftJars.Plugin.Fabric; internal static class FabricProjectFactory { public const string Fabric = "Fabric"; - public const string FabricSnapshot = "Fabric Snapshot"; public static readonly IEnumerable Projects = new List { @@ -14,11 +13,6 @@ internal static class FabricProjectFactory Name: Fabric, Description: "Fabric is a lightweight, experimental modding toolchain for Minecraft.", Url: "https://fabricmc.net", - Logo: Properties.Resources.Fabric), - new(Group: Group.Server, - Name: FabricSnapshot, - Description: "Fabric is a lightweight, experimental modding toolchain for Minecraft. Based on Minecraft snapshot versions", - Url: "https://fabricmc.net", - Logo: Properties.Resources.Fabric), + Logo: Properties.Resources.Fabric) }; } \ No newline at end of file diff --git a/MinecraftJars.Plugin/MinecraftJars.Plugin.Fabric/FabricVersionFactory.cs b/MinecraftJars.Plugin/MinecraftJars.Plugin.Fabric/FabricVersionFactory.cs index e334eb3..4e4808c 100644 --- a/MinecraftJars.Plugin/MinecraftJars.Plugin.Fabric/FabricVersionFactory.cs +++ b/MinecraftJars.Plugin/MinecraftJars.Plugin.Fabric/FabricVersionFactory.cs @@ -29,21 +29,15 @@ internal static class FabricVersionFactory if (!string.IsNullOrWhiteSpace(options.Version)) versionsApi.Games.RemoveAll(v => !v.Version.Equals(options.Version)); - - switch (project.Name) - { - case FabricProjectFactory.Fabric: - versionsApi.Games.RemoveAll(v => !v.Stable); - break; - case FabricProjectFactory.FabricSnapshot: - versionsApi.Games.RemoveAll(v => v.Stable); - break; - } + + if (!options.IncludeSnapshotBuilds) + versionsApi.Games.RemoveAll(v => !v.Stable); var versions = versionsApi.Games .Select(game => new FabricVersion( Project: project, - Version: game.Version) + Version: game.Version, + IsSnapShot: !game.Stable) { InstallerVersion = versionsApi.Installers.First().Version }).ToList(); diff --git a/MinecraftJars.Plugin/MinecraftJars.Plugin.Fabric/Model/FabricVersion.cs b/MinecraftJars.Plugin/MinecraftJars.Plugin.Fabric/Model/FabricVersion.cs index 6e7f951..848f421 100644 --- a/MinecraftJars.Plugin/MinecraftJars.Plugin.Fabric/Model/FabricVersion.cs +++ b/MinecraftJars.Plugin/MinecraftJars.Plugin.Fabric/Model/FabricVersion.cs @@ -6,7 +6,8 @@ namespace MinecraftJars.Plugin.Fabric.Model; public record FabricVersion( IProject Project, - string Version) : IVersion + string Version, + bool IsSnapShot) : IVersion { internal string InstallerVersion { get; init; } = string.Empty; diff --git a/MinecraftJars.Plugin/MinecraftJars.Plugin.Fabric/README.md b/MinecraftJars.Plugin/MinecraftJars.Plugin.Fabric/README.md index de47eef..4b68c7d 100644 --- a/MinecraftJars.Plugin/MinecraftJars.Plugin.Fabric/README.md +++ b/MinecraftJars.Plugin/MinecraftJars.Plugin.Fabric/README.md @@ -5,7 +5,6 @@ Provider for: - Fabric -- Fabric Snapshot ## Installing @@ -16,8 +15,8 @@ The plugin is already bundled with the core library [MinecraftJar.NET](../../REA The plugin has a few minor specialities compared to the core interfaces. If required the interface can be casted to it's instantiated classes. -- `IProvider` to [MohistProvider](MohistProvider.cs) -- `IProject` to [MohistProject](Model/MohistProject.cs) -- `IVersion` to [MohistVersion](Model/MohistVersion.cs) -- `IDownload` to [MohistDownload](Model/MohistDownload.cs) +- `IProvider` to [FabricProvider](FabricProvider.cs) +- `IProject` to [FabricProject](Model/FabricProject.cs) +- `IVersion` to [FabricVersion](Model/FabricVersion.cs) +- `IDownload` to [FabricDownload](Model/FabricDownload.cs) - No `Hash`, `ReleaseTime` or `Size` is provided \ No newline at end of file diff --git a/MinecraftJars.Plugin/MinecraftJars.Plugin.Mohist/Model/BuildApi/Build.cs b/MinecraftJars.Plugin/MinecraftJars.Plugin.Mohist/Model/MohistApi/Build.cs similarity index 94% rename from MinecraftJars.Plugin/MinecraftJars.Plugin.Mohist/Model/BuildApi/Build.cs rename to MinecraftJars.Plugin/MinecraftJars.Plugin.Mohist/Model/MohistApi/Build.cs index 3c0693f..84352e5 100644 --- a/MinecraftJars.Plugin/MinecraftJars.Plugin.Mohist/Model/BuildApi/Build.cs +++ b/MinecraftJars.Plugin/MinecraftJars.Plugin.Mohist/Model/MohistApi/Build.cs @@ -1,6 +1,6 @@ using System.Text.Json.Serialization; -namespace MinecraftJars.Plugin.Mohist.Model.BuildApi; +namespace MinecraftJars.Plugin.Mohist.Model.MohistApi; internal class Build { diff --git a/MinecraftJars.Plugin/MinecraftJars.Plugin.Mohist/Model/MohistVersion.cs b/MinecraftJars.Plugin/MinecraftJars.Plugin.Mohist/Model/MohistVersion.cs index 592b2c4..f93f63b 100644 --- a/MinecraftJars.Plugin/MinecraftJars.Plugin.Mohist/Model/MohistVersion.cs +++ b/MinecraftJars.Plugin/MinecraftJars.Plugin.Mohist/Model/MohistVersion.cs @@ -6,7 +6,8 @@ namespace MinecraftJars.Plugin.Mohist.Model; public record MohistVersion( IProject Project, - string Version) : IVersion + string Version, + bool IsSnapShot = false) : IVersion { public Task GetDownload(DownloadOptions? options = null, CancellationToken cancellationToken = default!) => MohistVersionFactory.GetDownload(options ?? new DownloadOptions(), this, cancellationToken); diff --git a/MinecraftJars.Plugin/MinecraftJars.Plugin.Mohist/MohistVersionFactory.cs b/MinecraftJars.Plugin/MinecraftJars.Plugin.Mohist/MohistVersionFactory.cs index 4911744..7929629 100644 --- a/MinecraftJars.Plugin/MinecraftJars.Plugin.Mohist/MohistVersionFactory.cs +++ b/MinecraftJars.Plugin/MinecraftJars.Plugin.Mohist/MohistVersionFactory.cs @@ -2,7 +2,7 @@ using MinecraftJars.Core.Downloads; using MinecraftJars.Core.Versions; using MinecraftJars.Plugin.Mohist.Model; -using MinecraftJars.Plugin.Mohist.Model.BuildApi; +using MinecraftJars.Plugin.Mohist.Model.MohistApi; namespace MinecraftJars.Plugin.Mohist; @@ -18,7 +18,6 @@ internal static class MohistVersionFactory VersionOptions options, CancellationToken cancellationToken) { - var versions = new List(); var project = MohistProjectFactory.Projects.Single(p => p.Name.Equals(projectName)); var availVersions = await HttpClient.GetFromJsonAsync>(MohistVersionRequestUri, cancellationToken); @@ -31,12 +30,12 @@ internal static class MohistVersionFactory availVersions.Reverse(); - versions.AddRange(availVersions - .Select(version => new MohistVersion( - Project: project, - Version: version - ))); - + var versions = availVersions + .Select(availVersion => new MohistVersion( + Project: project, + Version: availVersion) + ).ToList(); + return options.MaxRecords.HasValue ? versions.Take(options.MaxRecords.Value).ToList() : versions; diff --git a/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Models/DetailApi/Detail.cs b/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Models/MojangApi/Detail.cs similarity index 92% rename from MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Models/DetailApi/Detail.cs rename to MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Models/MojangApi/Detail.cs index ad1bb85..930af2c 100644 --- a/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Models/DetailApi/Detail.cs +++ b/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Models/MojangApi/Detail.cs @@ -1,6 +1,6 @@ using System.Text.Json.Serialization; -namespace MinecraftJars.Plugin.Mojang.Models.DetailApi; +namespace MinecraftJars.Plugin.Mojang.Models.MojangApi; internal class Detail { diff --git a/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Models/DetailApi/Downloads.cs b/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Models/MojangApi/Downloads.cs similarity index 71% rename from MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Models/DetailApi/Downloads.cs rename to MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Models/MojangApi/Downloads.cs index 6ca39e1..e51e300 100644 --- a/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Models/DetailApi/Downloads.cs +++ b/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Models/MojangApi/Downloads.cs @@ -1,6 +1,6 @@ using System.Text.Json.Serialization; -namespace MinecraftJars.Plugin.Mojang.Models.DetailApi; +namespace MinecraftJars.Plugin.Mojang.Models.MojangApi; internal class Downloads { diff --git a/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Models/DetailApi/JavaVersion.cs b/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Models/MojangApi/JavaVersion.cs similarity index 80% rename from MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Models/DetailApi/JavaVersion.cs rename to MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Models/MojangApi/JavaVersion.cs index d368a27..ea11b63 100644 --- a/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Models/DetailApi/JavaVersion.cs +++ b/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Models/MojangApi/JavaVersion.cs @@ -1,6 +1,6 @@ using System.Text.Json.Serialization; -namespace MinecraftJars.Plugin.Mojang.Models.DetailApi; +namespace MinecraftJars.Plugin.Mojang.Models.MojangApi; internal class JavaVersion { diff --git a/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Models/ManifestApi/Latest.cs b/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Models/MojangApi/Latest.cs similarity index 79% rename from MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Models/ManifestApi/Latest.cs rename to MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Models/MojangApi/Latest.cs index a6d0fca..acd4062 100644 --- a/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Models/ManifestApi/Latest.cs +++ b/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Models/MojangApi/Latest.cs @@ -1,6 +1,6 @@ using System.Text.Json.Serialization; -namespace MinecraftJars.Plugin.Mojang.Models.ManifestApi; +namespace MinecraftJars.Plugin.Mojang.Models.MojangApi; internal class Latest { diff --git a/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Models/ManifestApi/Manifest.cs b/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Models/MojangApi/Manifest.cs similarity index 80% rename from MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Models/ManifestApi/Manifest.cs rename to MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Models/MojangApi/Manifest.cs index 0cd025d..ba5fcb8 100644 --- a/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Models/ManifestApi/Manifest.cs +++ b/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Models/MojangApi/Manifest.cs @@ -1,6 +1,6 @@ using System.Text.Json.Serialization; -namespace MinecraftJars.Plugin.Mojang.Models.ManifestApi; +namespace MinecraftJars.Plugin.Mojang.Models.MojangApi; internal class Manifest { diff --git a/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Models/DetailApi/Server.cs b/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Models/MojangApi/Server.cs similarity index 83% rename from MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Models/DetailApi/Server.cs rename to MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Models/MojangApi/Server.cs index d92a438..fa66e2f 100644 --- a/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Models/DetailApi/Server.cs +++ b/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Models/MojangApi/Server.cs @@ -1,6 +1,6 @@ using System.Text.Json.Serialization; -namespace MinecraftJars.Plugin.Mojang.Models.DetailApi; +namespace MinecraftJars.Plugin.Mojang.Models.MojangApi; internal class Server { diff --git a/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Models/ManifestApi/Version.cs b/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Models/MojangApi/Version.cs similarity index 91% rename from MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Models/ManifestApi/Version.cs rename to MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Models/MojangApi/Version.cs index cd2cb0b..197e276 100644 --- a/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Models/ManifestApi/Version.cs +++ b/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Models/MojangApi/Version.cs @@ -1,6 +1,6 @@ using System.Text.Json.Serialization; -namespace MinecraftJars.Plugin.Mojang.Models.ManifestApi; +namespace MinecraftJars.Plugin.Mojang.Models.MojangApi; internal class Version { diff --git a/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Models/MojangVersion.cs b/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Models/MojangVersion.cs index eaa3efb..9084cd5 100644 --- a/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Models/MojangVersion.cs +++ b/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Models/MojangVersion.cs @@ -7,6 +7,7 @@ namespace MinecraftJars.Plugin.Mojang.Models; public record MojangVersion( IProject Project, string Version, + bool IsSnapShot, Os? Os = null) : IVersion { internal DateTime? ReleaseTime { get; init; } diff --git a/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/MojangProjectFactory.cs b/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/MojangProjectFactory.cs index e8e4e19..68cd485 100644 --- a/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/MojangProjectFactory.cs +++ b/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/MojangProjectFactory.cs @@ -6,9 +6,7 @@ namespace MinecraftJars.Plugin.Mojang; internal class MojangProjectFactory { public const string Vanilla = "Vanilla"; - public const string VanillaSnapshot = "Vanilla Snapshot"; public const string Bedrock = "Bedrock"; - public const string BedrockPreview = "Bedrock Preview"; public static readonly IEnumerable Projects = new List { @@ -17,20 +15,10 @@ internal class MojangProjectFactory Description: "The Mojang vanilla Minecraft experience without mod support.", Url: "https://www.minecraft.net/download/server", Logo: Properties.Resources.Vanilla), - new(Group: Group.Server, - Name: VanillaSnapshot, - Description: "A Snapshot is a testing version of Minecraft, periodically released by Mojang Studios.", - Url: "https://feedback.minecraft.net/hc/en-us/sections/360002267532-Snapshot-Information-and-Changelogs", - Logo: Properties.Resources.VanillaSnapshot), new(Group: Group.Bedrock, Name: Bedrock, Description: "Minecraft: Bedrock Edition refers to the multi-platform versions of Minecraft based on the Bedrock codebase.", Url: "https://www.minecraft.net/download/server/bedrock", - Logo: Properties.Resources.Bedrock), - new(Group: Group.Bedrock, - Name: BedrockPreview, - Description: "Minecraft Preview is an app players can use to test out beta features from Bedrock Edition. It works as a separate app, rather than the previous system of opt in beta content inside of the Bedrock Edition game itself.", - Url: "https://www.minecraft.net/download/server/bedrock", - Logo: Properties.Resources.BedrockPreview) + Logo: Properties.Resources.Bedrock) }; } \ No newline at end of file diff --git a/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/MojangVersionFactory.cs b/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/MojangVersionFactory.cs index 85122da..6851d2b 100644 --- a/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/MojangVersionFactory.cs +++ b/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/MojangVersionFactory.cs @@ -5,8 +5,7 @@ using MinecraftJars.Core.Downloads; using MinecraftJars.Core.Versions; using MinecraftJars.Plugin.Mojang.Models; -using MinecraftJars.Plugin.Mojang.Models.DetailApi; -using MinecraftJars.Plugin.Mojang.Models.ManifestApi; +using MinecraftJars.Plugin.Mojang.Models.MojangApi; using Group = MinecraftJars.Core.Projects.Group; namespace MinecraftJars.Plugin.Mojang; @@ -39,7 +38,7 @@ internal static partial class MojangVersionFactory VersionOptions options, CancellationToken cancellationToken) { - var versions = new List(); + var project = MojangProjectFactory.Projects.Single(p => p.Name.Equals(projectName)); var manifest = await HttpClient.GetFromJsonAsync(MojangVanillaRequestUri, cancellationToken); @@ -50,16 +49,18 @@ internal static partial class MojangVersionFactory if (!string.IsNullOrWhiteSpace(options.Version)) manifest.Versions.RemoveAll(v => !v.Id.Equals(options.Version)); - versions.AddRange(manifest.Versions - .Where(v => project.Name == MojangProjectFactory.Vanilla ? - v.Type.Equals("release", StringComparison.OrdinalIgnoreCase) : - !v.Type.Equals("release", StringComparison.OrdinalIgnoreCase)) - .Select(version => new MojangVersion( + if (!options.IncludeSnapshotBuilds) + manifest.Versions + .RemoveAll(v => !v.Type.Equals("release", StringComparison.OrdinalIgnoreCase)); + + var versions = manifest.Versions + .Select(v => new MojangVersion( Project: project, - Version: version.Id) { - ReleaseTime = version.ReleaseTime, - DetailUrl = version.Url - })); + Version: v.Id, + IsSnapShot: !v.Type.Equals("release", StringComparison.OrdinalIgnoreCase)) { + ReleaseTime = v.ReleaseTime, + DetailUrl = v.Url + }).ToList(); return options.MaxRecords.HasValue ? versions.Take(options.MaxRecords.Value).ToList() @@ -71,7 +72,6 @@ internal static partial class MojangVersionFactory VersionOptions options, CancellationToken cancellationToken) { - var versions = new List(); var project = MojangProjectFactory.Projects.Single(p => p.Name.Equals(projectName)); var request = new HttpRequestMessage(HttpMethod.Get, MojangBedrockRequestUri); @@ -86,44 +86,22 @@ internal static partial class MojangVersionFactory throw new InvalidOperationException("Could not acquire version details."); var html = await response.Content.ReadAsStringAsync(cancellationToken); - - foreach (var match in MojangBedrockDownloadLink().Matches(html).Cast()) - { - var url = match.Value; - - var version = match.Groups.Values - .Where(p => p.Name == "version") - .Select(p => p.Value) - .FirstOrDefault(); - - if (version == null) - continue; - - if (!string.IsNullOrWhiteSpace(options.Version) && !options.Version.Equals(version)) - continue; - - var isPreview = match.Groups["preview"].Value.Length > 0; - - if ((project.Name == MojangProjectFactory.Bedrock && isPreview) || - (project.Name == MojangProjectFactory.BedrockPreview && !isPreview)) - continue; - - var platform = match.Groups.Values - .Where(p => p.Name == "platform") - .Select(p => p.Value) - .FirstOrDefault() switch - { - "linux" => Os.Linux, - _ => Os.Windows - }; - - versions.Add(new MojangVersion( - Project: project, - Version: version, - Os: platform) { + + var versions = (from match in MojangBedrockDownloadLink().Matches(html) + let url = match.Value + let version = match.Groups["version"].Value + let isPreview = !string.IsNullOrWhiteSpace(match.Groups["preview"].Value) + let platform = match.Groups["platform"].Value.Equals("linux", StringComparison.OrdinalIgnoreCase) ? Os.Linux : Os.Windows + where !string.IsNullOrWhiteSpace(version) && (string.IsNullOrWhiteSpace(options.Version) || options.Version.Equals(version)) + where options.IncludeSnapshotBuilds || !isPreview + select new MojangVersion( + Project: project, + Version: version, + IsSnapShot: isPreview, + Os: platform) + { DetailUrl = url - }); - } + }).ToList(); return options.MaxRecords.HasValue ? versions.Take(options.MaxRecords.Value).ToList() diff --git a/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Properties/Resources.Designer.cs b/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Properties/Resources.Designer.cs index b19d3d8..9b0bf3e 100644 --- a/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Properties/Resources.Designer.cs +++ b/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Properties/Resources.Designer.cs @@ -1,7 +1,6 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -70,16 +69,6 @@ internal class Resources { } } - /// - /// Looks up a localized resource of type System.Byte[]. - /// - internal static byte[] BedrockPreview { - get { - object obj = ResourceManager.GetObject("BedrockPreview", resourceCulture); - return ((byte[])(obj)); - } - } - /// /// Looks up a localized resource of type System.Byte[]. /// @@ -99,15 +88,5 @@ internal class Resources { return ((byte[])(obj)); } } - - /// - /// Looks up a localized resource of type System.Byte[]. - /// - internal static byte[] VanillaSnapshot { - get { - object obj = ResourceManager.GetObject("VanillaSnapshot", resourceCulture); - return ((byte[])(obj)); - } - } } } diff --git a/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Properties/Resources.resx b/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Properties/Resources.resx index dcfbb84..0315254 100644 --- a/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Properties/Resources.resx +++ b/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Properties/Resources.resx @@ -121,16 +121,10 @@ ..\Resources\Bedrock.png;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - ..\Resources\BedrockPreview.png;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - ..\Resources\Mojang.png;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 ..\Resources\Vanilla.png;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - ..\Resources\VanillaSnapshot.png;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - \ No newline at end of file diff --git a/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/README.md b/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/README.md index ac5db0d..ef0e6fd 100644 --- a/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/README.md +++ b/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/README.md @@ -5,9 +5,7 @@ Provider for: - Vanilla -- Vanilla Preview - Bedrock -- Bedrock Preview ## Installing diff --git a/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Resources/BedrockPreview-24px.png b/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Resources/BedrockPreview-24px.png deleted file mode 100644 index 9ba864b..0000000 Binary files a/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Resources/BedrockPreview-24px.png and /dev/null differ diff --git a/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Resources/BedrockPreview-64px.png b/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Resources/BedrockPreview-64px.png deleted file mode 100644 index 426f9c3..0000000 Binary files a/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Resources/BedrockPreview-64px.png and /dev/null differ diff --git a/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Resources/BedrockPreview.png b/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Resources/BedrockPreview.png deleted file mode 100644 index 09931a7..0000000 Binary files a/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Resources/BedrockPreview.png and /dev/null differ diff --git a/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Resources/VanillaSnapshot-24px.png b/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Resources/VanillaSnapshot-24px.png deleted file mode 100644 index 4903777..0000000 Binary files a/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Resources/VanillaSnapshot-24px.png and /dev/null differ diff --git a/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Resources/VanillaSnapshot-64px.png b/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Resources/VanillaSnapshot-64px.png deleted file mode 100644 index b270ad5..0000000 Binary files a/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Resources/VanillaSnapshot-64px.png and /dev/null differ diff --git a/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Resources/VanillaSnapshot.png b/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Resources/VanillaSnapshot.png deleted file mode 100644 index 41df851..0000000 Binary files a/MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Resources/VanillaSnapshot.png and /dev/null differ diff --git a/MinecraftJars.Plugin/MinecraftJars.Plugin.Paper/Model/BuildApi/Application.cs b/MinecraftJars.Plugin/MinecraftJars.Plugin.Paper/Model/PaperApi/Application.cs similarity index 80% rename from MinecraftJars.Plugin/MinecraftJars.Plugin.Paper/Model/BuildApi/Application.cs rename to MinecraftJars.Plugin/MinecraftJars.Plugin.Paper/Model/PaperApi/Application.cs index beaac24..8f48069 100644 --- a/MinecraftJars.Plugin/MinecraftJars.Plugin.Paper/Model/BuildApi/Application.cs +++ b/MinecraftJars.Plugin/MinecraftJars.Plugin.Paper/Model/PaperApi/Application.cs @@ -1,6 +1,6 @@ using System.Text.Json.Serialization; -namespace MinecraftJars.Plugin.Paper.Model.BuildApi; +namespace MinecraftJars.Plugin.Paper.Model.PaperApi; public class Application { diff --git a/MinecraftJars.Plugin/MinecraftJars.Plugin.Paper/Model/BuildApi/Build.cs b/MinecraftJars.Plugin/MinecraftJars.Plugin.Paper/Model/PaperApi/Build.cs similarity index 89% rename from MinecraftJars.Plugin/MinecraftJars.Plugin.Paper/Model/BuildApi/Build.cs rename to MinecraftJars.Plugin/MinecraftJars.Plugin.Paper/Model/PaperApi/Build.cs index c143a66..b5a3238 100644 --- a/MinecraftJars.Plugin/MinecraftJars.Plugin.Paper/Model/BuildApi/Build.cs +++ b/MinecraftJars.Plugin/MinecraftJars.Plugin.Paper/Model/PaperApi/Build.cs @@ -1,6 +1,6 @@ using System.Text.Json.Serialization; -namespace MinecraftJars.Plugin.Paper.Model.BuildApi; +namespace MinecraftJars.Plugin.Paper.Model.PaperApi; public class Build { diff --git a/MinecraftJars.Plugin/MinecraftJars.Plugin.Paper/Model/BuildApi/Downloads.cs b/MinecraftJars.Plugin/MinecraftJars.Plugin.Paper/Model/PaperApi/Downloads.cs similarity index 75% rename from MinecraftJars.Plugin/MinecraftJars.Plugin.Paper/Model/BuildApi/Downloads.cs rename to MinecraftJars.Plugin/MinecraftJars.Plugin.Paper/Model/PaperApi/Downloads.cs index f9a4f19..1136fd3 100644 --- a/MinecraftJars.Plugin/MinecraftJars.Plugin.Paper/Model/BuildApi/Downloads.cs +++ b/MinecraftJars.Plugin/MinecraftJars.Plugin.Paper/Model/PaperApi/Downloads.cs @@ -1,6 +1,6 @@ using System.Text.Json.Serialization; -namespace MinecraftJars.Plugin.Paper.Model.BuildApi; +namespace MinecraftJars.Plugin.Paper.Model.PaperApi; public class Downloads { diff --git a/MinecraftJars.Plugin/MinecraftJars.Plugin.Paper/Model/ProjectApi/Project.cs b/MinecraftJars.Plugin/MinecraftJars.Plugin.Paper/Model/PaperApi/Project.cs similarity index 88% rename from MinecraftJars.Plugin/MinecraftJars.Plugin.Paper/Model/ProjectApi/Project.cs rename to MinecraftJars.Plugin/MinecraftJars.Plugin.Paper/Model/PaperApi/Project.cs index b6c8e95..3ce6704 100644 --- a/MinecraftJars.Plugin/MinecraftJars.Plugin.Paper/Model/ProjectApi/Project.cs +++ b/MinecraftJars.Plugin/MinecraftJars.Plugin.Paper/Model/PaperApi/Project.cs @@ -1,6 +1,6 @@ using System.Text.Json.Serialization; -namespace MinecraftJars.Plugin.Paper.Model.ProjectApi; +namespace MinecraftJars.Plugin.Paper.Model.PaperApi; internal class Project { diff --git a/MinecraftJars.Plugin/MinecraftJars.Plugin.Paper/Model/BuildApi/VersionBuilds.cs b/MinecraftJars.Plugin/MinecraftJars.Plugin.Paper/Model/PaperApi/VersionBuilds.cs similarity index 88% rename from MinecraftJars.Plugin/MinecraftJars.Plugin.Paper/Model/BuildApi/VersionBuilds.cs rename to MinecraftJars.Plugin/MinecraftJars.Plugin.Paper/Model/PaperApi/VersionBuilds.cs index abfdef4..194f42e 100644 --- a/MinecraftJars.Plugin/MinecraftJars.Plugin.Paper/Model/BuildApi/VersionBuilds.cs +++ b/MinecraftJars.Plugin/MinecraftJars.Plugin.Paper/Model/PaperApi/VersionBuilds.cs @@ -1,6 +1,6 @@ using System.Text.Json.Serialization; -namespace MinecraftJars.Plugin.Paper.Model.BuildApi; +namespace MinecraftJars.Plugin.Paper.Model.PaperApi; internal class BuildVersions { diff --git a/MinecraftJars.Plugin/MinecraftJars.Plugin.Paper/Model/PaperVersion.cs b/MinecraftJars.Plugin/MinecraftJars.Plugin.Paper/Model/PaperVersion.cs index 611f1d8..934f17c 100644 --- a/MinecraftJars.Plugin/MinecraftJars.Plugin.Paper/Model/PaperVersion.cs +++ b/MinecraftJars.Plugin/MinecraftJars.Plugin.Paper/Model/PaperVersion.cs @@ -6,7 +6,8 @@ namespace MinecraftJars.Plugin.Paper.Model; public record PaperVersion( IProject Project, - string Version) : IVersion + string Version, + bool IsSnapShot = false) : IVersion { public Task GetDownload(DownloadOptions? options = null, CancellationToken cancellationToken = default!) => PaperVersionFactory.GetDownload(options ?? new DownloadOptions(), this, cancellationToken); diff --git a/MinecraftJars.Plugin/MinecraftJars.Plugin.Paper/PaperVersionFactory.cs b/MinecraftJars.Plugin/MinecraftJars.Plugin.Paper/PaperVersionFactory.cs index 3c474e8..df2403e 100644 --- a/MinecraftJars.Plugin/MinecraftJars.Plugin.Paper/PaperVersionFactory.cs +++ b/MinecraftJars.Plugin/MinecraftJars.Plugin.Paper/PaperVersionFactory.cs @@ -2,8 +2,7 @@ using MinecraftJars.Core.Downloads; using MinecraftJars.Core.Versions; using MinecraftJars.Plugin.Paper.Model; -using MinecraftJars.Plugin.Paper.Model.BuildApi; -using MinecraftJars.Plugin.Paper.Model.ProjectApi; +using MinecraftJars.Plugin.Paper.Model.PaperApi; namespace MinecraftJars.Plugin.Paper; diff --git a/MinecraftJars.Plugin/MinecraftJars.Plugin.Pocketmine/Model/PocketmineVersion.cs b/MinecraftJars.Plugin/MinecraftJars.Plugin.Pocketmine/Model/PocketmineVersion.cs index 3c149ec..fa453ed 100644 --- a/MinecraftJars.Plugin/MinecraftJars.Plugin.Pocketmine/Model/PocketmineVersion.cs +++ b/MinecraftJars.Plugin/MinecraftJars.Plugin.Pocketmine/Model/PocketmineVersion.cs @@ -6,7 +6,8 @@ namespace MinecraftJars.Plugin.Pocketmine.Model; public record PocketmineVersion( IProject Project, - string Version) : IVersion + string Version, + bool IsSnapShot) : IVersion { internal PocketmineDownload Download { get; init; } = default!; diff --git a/MinecraftJars.Plugin/MinecraftJars.Plugin.Pocketmine/PocketmineVersionFactory.cs b/MinecraftJars.Plugin/MinecraftJars.Plugin.Pocketmine/PocketmineVersionFactory.cs index 6afc0f4..a8eac91 100644 --- a/MinecraftJars.Plugin/MinecraftJars.Plugin.Pocketmine/PocketmineVersionFactory.cs +++ b/MinecraftJars.Plugin/MinecraftJars.Plugin.Pocketmine/PocketmineVersionFactory.cs @@ -35,18 +35,21 @@ internal static class PocketmineVersionFactory } releaseApi.RemoveAll(r => !r.Assets.Any()); - var versions = releaseApi - .Select(release => new { release, asset = release.Assets.First() }) - .Select(t => new PocketmineVersion( + var versions = (from release in releaseApi + let asset = release.Assets.First() + let isSnapShot = release.TagName.Contains("beta", StringComparison.OrdinalIgnoreCase) + where options.IncludeSnapshotBuilds || !isSnapShot + select new PocketmineVersion( Project: project, - Version: t.release.TagName) + Version: release.TagName, + IsSnapShot: isSnapShot) { Download = new PocketmineDownload( - FileName: t.asset.Name, - Size: t.asset.Size, - BuildId: t.release.Id.ToString(), - Url: t.asset.BrowserDownloadUrl, - ReleaseTime: new[] { t.asset.CreatedAt, t.asset.UpdatedAt }.Max()) + FileName: asset.Name, + Size: asset.Size, + BuildId: release.Id.ToString(), + Url: asset.BrowserDownloadUrl, + ReleaseTime: new[] { asset.CreatedAt, asset.UpdatedAt }.Max()) }).ToList(); return options.MaxRecords.HasValue diff --git a/MinecraftJars.Plugin/MinecraftJars.Plugin.Purpur/Model/BuildApi/Build.cs b/MinecraftJars.Plugin/MinecraftJars.Plugin.Purpur/Model/PurpurApi/Build.cs similarity index 91% rename from MinecraftJars.Plugin/MinecraftJars.Plugin.Purpur/Model/BuildApi/Build.cs rename to MinecraftJars.Plugin/MinecraftJars.Plugin.Purpur/Model/PurpurApi/Build.cs index dbd5b3a..ec6c750 100644 --- a/MinecraftJars.Plugin/MinecraftJars.Plugin.Purpur/Model/BuildApi/Build.cs +++ b/MinecraftJars.Plugin/MinecraftJars.Plugin.Purpur/Model/PurpurApi/Build.cs @@ -1,6 +1,6 @@ using System.Text.Json.Serialization; -namespace MinecraftJars.Plugin.Purpur.Model.BuildApi; +namespace MinecraftJars.Plugin.Purpur.Model.PurpurApi; internal class Build { diff --git a/MinecraftJars.Plugin/MinecraftJars.Plugin.Purpur/Model/BuildApi/Builds.cs b/MinecraftJars.Plugin/MinecraftJars.Plugin.Purpur/Model/PurpurApi/Builds.cs similarity index 80% rename from MinecraftJars.Plugin/MinecraftJars.Plugin.Purpur/Model/BuildApi/Builds.cs rename to MinecraftJars.Plugin/MinecraftJars.Plugin.Purpur/Model/PurpurApi/Builds.cs index 324a3f7..758ea64 100644 --- a/MinecraftJars.Plugin/MinecraftJars.Plugin.Purpur/Model/BuildApi/Builds.cs +++ b/MinecraftJars.Plugin/MinecraftJars.Plugin.Purpur/Model/PurpurApi/Builds.cs @@ -1,6 +1,6 @@ using System.Text.Json.Serialization; -namespace MinecraftJars.Plugin.Purpur.Model.BuildApi; +namespace MinecraftJars.Plugin.Purpur.Model.PurpurApi; internal class Builds { diff --git a/MinecraftJars.Plugin/MinecraftJars.Plugin.Purpur/Model/ProjectApi/Project.cs b/MinecraftJars.Plugin/MinecraftJars.Plugin.Purpur/Model/PurpurApi/Project.cs similarity index 80% rename from MinecraftJars.Plugin/MinecraftJars.Plugin.Purpur/Model/ProjectApi/Project.cs rename to MinecraftJars.Plugin/MinecraftJars.Plugin.Purpur/Model/PurpurApi/Project.cs index e0d13fb..3dea0a9 100644 --- a/MinecraftJars.Plugin/MinecraftJars.Plugin.Purpur/Model/ProjectApi/Project.cs +++ b/MinecraftJars.Plugin/MinecraftJars.Plugin.Purpur/Model/PurpurApi/Project.cs @@ -1,6 +1,6 @@ using System.Text.Json.Serialization; -namespace MinecraftJars.Plugin.Purpur.Model.ProjectApi; +namespace MinecraftJars.Plugin.Purpur.Model.PurpurApi; internal class Project { diff --git a/MinecraftJars.Plugin/MinecraftJars.Plugin.Purpur/Model/BuildApi/VersionBuilds.cs b/MinecraftJars.Plugin/MinecraftJars.Plugin.Purpur/Model/PurpurApi/VersionBuilds.cs similarity index 84% rename from MinecraftJars.Plugin/MinecraftJars.Plugin.Purpur/Model/BuildApi/VersionBuilds.cs rename to MinecraftJars.Plugin/MinecraftJars.Plugin.Purpur/Model/PurpurApi/VersionBuilds.cs index 09f69f9..a5dd4a0 100644 --- a/MinecraftJars.Plugin/MinecraftJars.Plugin.Purpur/Model/BuildApi/VersionBuilds.cs +++ b/MinecraftJars.Plugin/MinecraftJars.Plugin.Purpur/Model/PurpurApi/VersionBuilds.cs @@ -1,6 +1,6 @@ using System.Text.Json.Serialization; -namespace MinecraftJars.Plugin.Purpur.Model.BuildApi; +namespace MinecraftJars.Plugin.Purpur.Model.PurpurApi; internal class VersionBuilds { diff --git a/MinecraftJars.Plugin/MinecraftJars.Plugin.Purpur/Model/PurpurVersion.cs b/MinecraftJars.Plugin/MinecraftJars.Plugin.Purpur/Model/PurpurVersion.cs index b3fa43b..9684320 100644 --- a/MinecraftJars.Plugin/MinecraftJars.Plugin.Purpur/Model/PurpurVersion.cs +++ b/MinecraftJars.Plugin/MinecraftJars.Plugin.Purpur/Model/PurpurVersion.cs @@ -6,7 +6,8 @@ namespace MinecraftJars.Plugin.Purpur.Model; public record PurpurVersion( IProject Project, - string Version) : IVersion + string Version, + bool IsSnapShot = false) : IVersion { public Task GetDownload(DownloadOptions? options = null, CancellationToken cancellationToken = default!) => PurpurVersionFactory.GetDownload(options ?? new DownloadOptions(), this, cancellationToken); diff --git a/MinecraftJars.Plugin/MinecraftJars.Plugin.Purpur/PurpurVersionFactory.cs b/MinecraftJars.Plugin/MinecraftJars.Plugin.Purpur/PurpurVersionFactory.cs index 66db076..b55934d 100644 --- a/MinecraftJars.Plugin/MinecraftJars.Plugin.Purpur/PurpurVersionFactory.cs +++ b/MinecraftJars.Plugin/MinecraftJars.Plugin.Purpur/PurpurVersionFactory.cs @@ -2,8 +2,7 @@ using MinecraftJars.Core.Downloads; using MinecraftJars.Core.Versions; using MinecraftJars.Plugin.Purpur.Model; -using MinecraftJars.Plugin.Purpur.Model.BuildApi; -using MinecraftJars.Plugin.Purpur.Model.ProjectApi; +using MinecraftJars.Plugin.Purpur.Model.PurpurApi; namespace MinecraftJars.Plugin.Purpur; @@ -21,7 +20,6 @@ internal static class PurpurVersionFactory VersionOptions options, CancellationToken cancellationToken) { - var versions = new List(); var project = PurpurProjectFactory.Projects.Single(p => p.Name.Equals(projectName)); var projectApi = await HttpClient.GetFromJsonAsync(PurpurProjectRequestUri, cancellationToken); @@ -33,11 +31,12 @@ internal static class PurpurVersionFactory projectApi.Versions.RemoveAll(v => !v.Equals(options.Version)); projectApi.Versions.Reverse(); - versions.AddRange(projectApi.Versions + + var versions = projectApi.Versions .Select(projectApiVersion => new PurpurVersion( Project: project, - Version: projectApiVersion - ))); + Version: projectApiVersion) + ).ToList(); return options.MaxRecords.HasValue ? versions.Take(options.MaxRecords.Value).ToList() diff --git a/MinecraftJars.Plugin/MinecraftJars.Plugin.Spigot/Model/SpigotVersion.cs b/MinecraftJars.Plugin/MinecraftJars.Plugin.Spigot/Model/SpigotVersion.cs index 5cd4044..6f15401 100644 --- a/MinecraftJars.Plugin/MinecraftJars.Plugin.Spigot/Model/SpigotVersion.cs +++ b/MinecraftJars.Plugin/MinecraftJars.Plugin.Spigot/Model/SpigotVersion.cs @@ -7,7 +7,8 @@ namespace MinecraftJars.Plugin.Spigot.Model; public record SpigotVersion( IProject Project, string Version, - bool RequiresLocalBuild = false) : IVersion + bool RequiresLocalBuild = false, + bool IsSnapShot = false) : IVersion { internal DateTime? ReleaseTime { get; init; } internal string DetailUrl { get; init; } = string.Empty; diff --git a/MinecraftJars.Plugin/MinecraftJars.Plugin.Spigot/SpigotVersionFactory.cs b/MinecraftJars.Plugin/MinecraftJars.Plugin.Spigot/SpigotVersionFactory.cs index a39fdf2..9f8137b 100644 --- a/MinecraftJars.Plugin/MinecraftJars.Plugin.Spigot/SpigotVersionFactory.cs +++ b/MinecraftJars.Plugin/MinecraftJars.Plugin.Spigot/SpigotVersionFactory.cs @@ -41,7 +41,6 @@ internal static partial class SpigotVersionFactory VersionOptions options, CancellationToken cancellationToken) { - var versions = new List(); var project = SpigotProjectFactory.Projects.Single(p => p.Name.Equals(projectName)); var request = new HttpRequestMessage(HttpMethod.Get, SpigotRequestUri); @@ -57,18 +56,21 @@ internal static partial class SpigotVersionFactory var html = await response.Content.ReadAsStringAsync(cancellationToken); - versions.AddRange(SpigotVersions() - .Matches(html) - .Where(m => string.IsNullOrWhiteSpace(options.Version) || m.Groups["version"].Value.Equals(options.Version)) - .Select(m => new SpigotVersion( + var versions = (from match in SpigotVersions().Matches(html) + let version = match.Groups["version"].Value + let jsonFile = match.Groups["json"].Value + let releaseTime = DateTime.Parse(match.Groups["date"].Value, new CultureInfo("en-US")) + where !string.IsNullOrWhiteSpace(version) && + (string.IsNullOrWhiteSpace(options.Version) || options.Version.Equals(version)) + orderby releaseTime descending + select new SpigotVersion( Project: project, - Version: m.Groups["version"].Value, + Version: version, RequiresLocalBuild: true) { - DetailUrl = $"{SpigotRequestUri}/{m.Groups["json"].Value}", - ReleaseTime = DateTime.Parse(m.Groups["date"].Value, new CultureInfo("en-US")) - }) - .OrderByDescending(v => v.ReleaseTime)); + DetailUrl = $"{SpigotRequestUri}/{jsonFile}", + ReleaseTime = releaseTime + }).ToList(); return options.MaxRecords.HasValue ? versions.Take(options.MaxRecords.Value).ToList() @@ -80,7 +82,6 @@ internal static partial class SpigotVersionFactory VersionOptions options, CancellationToken cancellationToken) { - var versions = new List(); var project = SpigotProjectFactory.Projects.Single(p => p.Name.Equals(projectName)); var requestUrl = BungeeCoordRequestUri + (options.MaxRecords.HasValue @@ -92,17 +93,19 @@ internal static partial class SpigotVersionFactory if (job == null) throw new InvalidOperationException("Could not acquire version details."); - versions.AddRange(job.Builds - .Where(b => !b.InProgress && - b.Result.Equals("success", StringComparison.OrdinalIgnoreCase)) - .Where(b => string.IsNullOrWhiteSpace(options.Version) || b.Number.ToString().Equals(options.Version)) - .Select(b => new SpigotVersion( - project, - b.Number.ToString()) - { - ReleaseTime = DateTimeOffset.FromUnixTimeMilliseconds(b.Timestamp).DateTime, - DetailUrl = $"{b.Url}artifact/{b.Artifacts.First().RelativePath}" - })); + var versions = (from build in job.Builds + where !build.InProgress && + build.Result.Equals("success", StringComparison.OrdinalIgnoreCase) + let version = build.Number.ToString() + let artifact = build.Artifacts.First() + where string.IsNullOrWhiteSpace(options.Version) || options.Version.Equals(build.Number.ToString()) + select new SpigotVersion( + Project: project, + Version: version) + { + ReleaseTime = DateTimeOffset.FromUnixTimeMilliseconds(build.Timestamp).DateTime, + DetailUrl = $"{build.Url}artifact/{artifact.RelativePath}" + }).ToList(); return versions; } diff --git a/MinecraftJars.Tests/VersionTests.cs b/MinecraftJars.Tests/VersionTests.cs index 1a95001..daffb01 100644 --- a/MinecraftJars.Tests/VersionTests.cs +++ b/MinecraftJars.Tests/VersionTests.cs @@ -59,4 +59,39 @@ public async Task GetVersions_SpecificVersion(string projectName) TestContext.Progress.WriteLine("{0}: Specific version {1} found", nameof(GetVersions_SpecificVersion), version.Version); } + + [TestCase("Vanilla")] + [TestCase("Bedrock")] + [TestCase("Pocketmine")] + [Order(4)] + public async Task GetVersions_ContainsSnapshot(string projectName) + { + var project = ProviderManager.GetProjects().Single(p => p.Name.Equals(projectName)); + var provider = ProviderManager.GetProvider(project); + + var versions = + (await provider.GetVersions(project.Name, new VersionOptions { IncludeSnapshotBuilds = true })).ToList(); + + Assert.That(versions.Any(v => v.IsSnapShot), Is.True); + + TestContext.Progress.WriteLine("{0}: {1} snapshot version found", + nameof(GetVersions_ContainsSnapshot), versions.Count(v => v.IsSnapShot)); + } + + [TestCase("Vanilla")] + [TestCase("Bedrock")] + [TestCase("Pocketmine")] + [Order(5)] + public async Task GetVersions_ContainsNoSnapshot(string projectName) + { + var project = ProviderManager.GetProjects().Single(p => p.Name.Equals(projectName)); + var provider = ProviderManager.GetProvider(project); + + var versions = + (await provider.GetVersions(project.Name, new VersionOptions { IncludeSnapshotBuilds = false })).ToList(); + + Assert.That(versions.Any(v => v.IsSnapShot), Is.False); + + TestContext.Progress.WriteLine("{0}: No snapshot version found", nameof(GetVersions_ContainsNoSnapshot)); + } } \ No newline at end of file diff --git a/README.md b/README.md index 79f2b87..a189964 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ If I've helped you and you like some of my work, feel free to buy me a coffee Following provider plugins are already bundled with MinecraftJars.NET: ![Mojang](MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang/Resources/Mojang-24px.png) [Mojang](MinecraftJars.Plugin/MinecraftJars.Plugin.Mojang): -Vanilla, Vanilla Snapshot, Bedrock, Bedrock Preview +Vanilla, Bedrock ![Paper](MinecraftJars.Plugin/MinecraftJars.Plugin.Paper/Resources/Paper-24px.png) [Paper](MinecraftJars.Plugin/MinecraftJars.Plugin.Paper): Paper, Folia, Velocity, Waterfall @@ -44,7 +44,7 @@ Pocketmine Mohist ![Fabric](MinecraftJars.Plugin/MinecraftJars.Plugin.Fabric/Resources/Fabric-24px.png) [Fabric](MinecraftJars.Plugin/MinecraftJars.Plugin.Fabric): -Fabric, Fabric Snapshot +Fabric ![Spigot](MinecraftJars.Plugin/MinecraftJars.Plugin.Spigot/Resources/Spigot-24px.png) [Spigot](MinecraftJars.Plugin/MinecraftJars.Plugin.Spigot) (**Important:** see details in Plugin Readme): Spigot, BungeeCord