Skip to content

Commit

Permalink
Removed ProviderOptions as it had no use and created an unnecessary d…
Browse files Browse the repository at this point in the history
…ependency
  • Loading branch information
tekgator committed Jun 3, 2023
1 parent d6032c1 commit c944a06
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 53 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

## [1.4.2] - 2023-06-03

### Removed
- Removed ProviderOptions as it had no use and created an unnecessary dependency

### Added
- Added MinecraftJarOptions so the optional IHttpClientFactory can be provided

### Fixed
- Removed unnecessary dependency of MinecraftJars.Core causing Nuget installation to fail


## [1.4.1] - 2023-06-03

### Changed
Expand Down
5 changes: 0 additions & 5 deletions MinecraftJars.Core/Providers/IMinecraftProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ namespace MinecraftJars.Core.Providers;

public interface IMinecraftProvider
{
/// <summary>
/// The options the provider manager has been provided with
/// </summary>
ProviderOptions ProviderOptions { get; }

/// <summary>
/// Name of the provider e.g. Mojang, PaperMC, etc.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\MinecraftJars.Core\MinecraftJars.Core.csproj" />
<ProjectReference Include="..\..\MinecraftJars\MinecraftJars.csproj" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Microsoft.Extensions.DependencyInjection;
using MinecraftJars.Core.Providers;

namespace MinecraftJars.Extension.DependencyInjection;

Expand All @@ -8,7 +7,7 @@ public static class ServiceCollectionExtensions
public static IServiceCollection AddMinecraftJar(this IServiceCollection services)
{
services.AddHttpClient();
services.AddScoped<IMinecraftJar, MinecraftJar>(sp => new MinecraftJar(new ProviderOptions
services.AddScoped<IMinecraftJar, MinecraftJar>(sp => new MinecraftJar(new MinecraftJarOptions()
{
HttpClientFactory = sp.GetRequiredService<IHttpClientFactory>()
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,11 @@ namespace MinecraftJars.Plugin.Fabric;
public class FabricProvider : IMinecraftProvider
{
[ImportingConstructor]
public FabricProvider(
PluginHttpClientFactory httpClientFactory,
ProviderOptions? options)
public FabricProvider(PluginHttpClientFactory httpClientFactory)
{
FabricVersionFactory.HttpClientFactory = httpClientFactory;
ProviderOptions = options ?? new ProviderOptions();
}

public ProviderOptions ProviderOptions { get; }
public string Name => "Fabric";
public byte[] Logo => Properties.Resources.Fabric;
public IEnumerable<IMinecraftProject> Projects => FabricProjectFactory.Projects;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,11 @@ namespace MinecraftJars.Plugin.Mohist;
public class MohistProvider : IMinecraftProvider
{
[ImportingConstructor]
public MohistProvider(
PluginHttpClientFactory httpClientFactory,
ProviderOptions? options)
public MohistProvider(PluginHttpClientFactory httpClientFactory)
{
MohistVersionFactory.HttpClientFactory = httpClientFactory;
ProviderOptions = options ?? new ProviderOptions();
}

public ProviderOptions ProviderOptions { get; }
public string Name => "Mohist";
public byte[] Logo => Properties.Resources.Mohist;
public IEnumerable<IMinecraftProject> Projects => MohistProjectFactory.Projects;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,11 @@ namespace MinecraftJars.Plugin.Mojang;
public class MojangProvider : IMinecraftProvider
{
[ImportingConstructor]
public MojangProvider(
PluginHttpClientFactory httpClientFactory,
ProviderOptions? options)
public MojangProvider(PluginHttpClientFactory httpClientFactory)
{
MojangVersionFactory.HttpClientFactory = httpClientFactory;
ProviderOptions = options ?? new ProviderOptions();
}

public ProviderOptions ProviderOptions { get; }
public string Name => "Mojang";
public byte[] Logo => Properties.Resources.Mojang;
public IEnumerable<IMinecraftProject> Projects => MojangProjectFactory.Projects;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,11 @@ namespace MinecraftJars.Plugin.Paper;
public class PaperProvider : IMinecraftProvider
{
[ImportingConstructor]
public PaperProvider(
PluginHttpClientFactory httpClientFactory,
ProviderOptions? options)
public PaperProvider(PluginHttpClientFactory httpClientFactory)
{
PaperVersionFactory.HttpClientFactory = httpClientFactory;
ProviderOptions = options ?? new ProviderOptions();
}

public ProviderOptions ProviderOptions { get; }
public string Name => "Paper";
public byte[] Logo => Properties.Resources.Paper;
public IEnumerable<IMinecraftProject> Projects => PaperProjectFactory.Projects;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,11 @@ namespace MinecraftJars.Plugin.Pocketmine;
public class PocketmineProvider : IMinecraftProvider
{
[ImportingConstructor]
public PocketmineProvider(
PluginHttpClientFactory httpClientFactory,
ProviderOptions? options)
public PocketmineProvider(PluginHttpClientFactory httpClientFactory)
{
PocketmineVersionFactory.HttpClientFactory = httpClientFactory;
ProviderOptions = options ?? new ProviderOptions();
}

public ProviderOptions ProviderOptions { get; }
public string Name => "Pocketmine";
public byte[] Logo => Properties.Resources.Pocketmine;
public IEnumerable<IMinecraftProject> Projects => PocketmineProjectFactory.Projects;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,11 @@ namespace MinecraftJars.Plugin.Purpur;
public class PurpurProvider : IMinecraftProvider
{
[ImportingConstructor]
public PurpurProvider(
PluginHttpClientFactory httpClientFactory,
ProviderOptions? options)
public PurpurProvider(PluginHttpClientFactory httpClientFactory)
{
PurpurVersionFactory.HttpClientFactory = httpClientFactory;
ProviderOptions = options ?? new ProviderOptions();
}

public ProviderOptions ProviderOptions { get; }
public string Name => "Purpur";
public byte[] Logo => Properties.Resources.Purpur;
public IEnumerable<IMinecraftProject> Projects => PurpurProjectFactory.Projects;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,11 @@ namespace MinecraftJars.Plugin.Spigot;
public class SpigotProvider : IMinecraftProvider
{
[ImportingConstructor]
public SpigotProvider(
PluginHttpClientFactory httpClientFactory,
ProviderOptions? options)
public SpigotProvider(PluginHttpClientFactory httpClientFactory)
{
SpigotVersionFactory.HttpClientFactory = httpClientFactory;
ProviderOptions = options ?? new ProviderOptions();
}

public ProviderOptions ProviderOptions { get; }
public string Name => "Spigot";
public byte[] Logo => Properties.Resources.Spigot;
public IEnumerable<IMinecraftProject> Projects => SpigotProjectFactory.Projects;
Expand Down
10 changes: 3 additions & 7 deletions MinecraftJars/MinecraftJar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,12 @@ public class MinecraftJar : IMinecraftJar
[ImportMany(typeof(IMinecraftProvider))]
private IEnumerable<IMinecraftProvider> _providers;

[Export]
private ProviderOptions ProviderOptions { get; }

[Export]
private PluginHttpClientFactory HttpClientFactory { get; }
public MinecraftJar(ProviderOptions? options = null)

public MinecraftJar(MinecraftJarOptions? options = null)
{
ProviderOptions = options ?? new ProviderOptions();
HttpClientFactory = new PluginHttpClientFactory(ProviderOptions.HttpClientFactory);
HttpClientFactory = new PluginHttpClientFactory(options?.HttpClientFactory);

var path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? ".";
var catalog = new AggregateCatalog();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
namespace MinecraftJars.Core.Providers;
namespace MinecraftJars;

public class ProviderOptions
public class MinecraftJarOptions
{
/// <summary>
/// If provided the CreateClient Method is utilized to create a HttpClient
/// otherwise a new HttpClient is instantiated by the MinecraftJarManager
/// </summary>
public IHttpClientFactory? HttpClientFactory { get; init; }
public IHttpClientFactory? HttpClientFactory { get; init; }
}

0 comments on commit c944a06

Please sign in to comment.