ServerJars 1.2.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package ServerJars --version 1.2.0                
NuGet\Install-Package ServerJars -Version 1.2.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ServerJars" Version="1.2.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ServerJars --version 1.2.0                
#r "nuget: ServerJars, 1.2.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install ServerJars as a Cake Addin
#addin nuget:?package=ServerJars&version=1.2.0

// Install ServerJars as a Cake Tool
#tool nuget:?package=ServerJars&version=1.2.0                

ServerJars ServerJars .NET API

Implementation of the ServerJars.com API as a .NET library.

Please see API Documentation for further details

Installing

Multiple options are available to install within your project:

  1. Install, using the Nuget Gallery

  2. Install using the Package Manager Console:

    Install-Package ServerJars 
    
  3. Install using .NET CLI

    dotnet add package ServerJars
    

Usage

Simply instantiate the ServerJars class and use it's methods to gather information from the API.

using ServerJarsAPI;
using ServerJarsAPI.Events;
using ServerJarsAPI.Extensions;
using System.Text.Json;

var serverJar = new ServerJars();

// GetTypes
var types = await serverJar.GetTypes();
Console.WriteLine(JsonSerializer.Serialize(types, jsonOptions));

// GetTypes.AsDictionary() extension
var dict = types.AsDictionary();
Console.WriteLine(string.Join(Environment.NewLine, dict.Select((kv) => $"{kv.Key}: {string.Join(", ", kv.Value)}")));

// GetDetails
var details = await serverJar.GetDetails("servers", "spigot", "1.19.1");
Console.WriteLine(JsonSerializer.Serialize(details, jsonOptions));

// GetLatest
var latestDetails = await serverJar.GetLatest("servers", "spigot");
Console.WriteLine(JsonSerializer.Serialize(latestDetails, jsonOptions));

// GetAllDetails
var allDetails = await serverJar.GetAllDetails("servers", "spigot", 5u);
Console.WriteLine(JsonSerializer.Serialize(allDetails, jsonOptions));

// GetJar Method 1 (including progress)
using var fileStream1 = File.Create("./server1.jar");
Progress<ProgressEventArgs> progress = new();
progress.ProgressChanged += (_, e) =>
{
    Console.Write($"\rProgress: {e.ProgressPercentage}% ({e.BytesTransferred / 1024 / 1024}MB / {e.TotalBytes / 1024 / 1024}MB)          ");
};
await serverJar.GetJar(fileStream1, "servers", "spigot", progress: progress);
await fileStream1.FlushAsync();
Console.WriteLine($"\nDownloaded {fileStream1.Length / 1024 / 1024}MB to {fileStream1.Name}");

// GetJar Method 2
using (var stream = await serverJar.GetJar("servers", "spigot", "1.19.1"))
{
    using var fileStream2 = File.Create("./server2.jar");
    await stream.CopyToAsync(fileStream2);
    Console.WriteLine($"Downloaded {fileStream2.Length / 1024 / 1024}MB to {fileStream2.Name}");
}

ServerJarExt

ServerJarExt is an extended version of the API e.g. providing the JarTypes directly as Dictionary and adds a few more information to the JarDetails in an JarDetailsExt Version.

Demo application

Have a look at the Console Demo within the repository. It will run straight out of the box to give you a hint what the library can do for you.

Support

I try to be responsive to Stack Overflow questions in the serverjars-net tag and issues logged on this GitHub repository.

If I've helped you, feel free to buy me a coffee or see the Sponsor link at the top right of the GitHub page.

<a href="https://www.buymeacoffee.com/tekgator" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png" alt="Buy Me A Coffee" style="height: 41px !important;width: 174px !important;box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;-webkit-box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;" ></a>

Dependencies and Credits

The project has no special dependencies except to the awesome API from the ServerJars.com website.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.0

    • No dependencies.
  • net7.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.2.1 391 12/25/2022
1.2.0 323 12/25/2022
1.1.1 325 12/6/2022
1.1.0 318 12/6/2022
1.0.2 335 12/2/2022
1.0.1 342 12/2/2022
1.0.0 351 11/30/2022