Implementation of the ServerJars.com API as a .NET library.
Please see API Documentation for further details
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 and you like some of my work, feel free to buy me a coffee ☕ (or more likely a beer 🍺)
Multiple options are available to install within your project:
Install, using the Nuget Gallery
Install using the Package Manager Console:
Install-PackageServerJars
Install using .NET CLI
dotnet add package ServerJars
Simply instantiate the ServerJars class and use it's methods to gather information from the API.
usingServerJarsAPI;usingServerJarsAPI.Events;usingServerJarsAPI.Extensions;usingSystem.Text.Json;varserverJar=newServerJars();// GetTypesvartypes=awaitserverJar.GetTypes();Console.WriteLine(JsonSerializer.Serialize(types,jsonOptions));// GetTypes.AsDictionary() extensionvardict=types.AsDictionary();Console.WriteLine(string.Join(Environment.NewLine,dict.Select((kv)=>$"{kv.Key}: {string.Join(", ",kv.Value)}")));// GetDetailsvardetails=awaitserverJar.GetDetails("servers","spigot","1.19.1");Console.WriteLine(JsonSerializer.Serialize(details,jsonOptions));// GetLatestvarlatestDetails=awaitserverJar.GetLatest("servers","spigot");Console.WriteLine(JsonSerializer.Serialize(latestDetails,jsonOptions));// GetAllDetailsvarallDetails=awaitserverJar.GetAllDetails("servers","spigot",5u);Console.WriteLine(JsonSerializer.Serialize(allDetails,jsonOptions));// GetJar Method 1 (including progress)usingvarfileStream1=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) ");};awaitserverJar.GetJar(fileStream1,"servers","spigot",progress:progress);awaitfileStream1.FlushAsync();Console.WriteLine($"\nDownloaded {fileStream1.Length/1024/1024}MB to {fileStream1.Name}");// GetJar Method 2using(varstream=awaitserverJar.GetJar("servers","spigot","1.19.1")){usingvarfileStream2=File.Create("./server2.jar");awaitstream.CopyToAsync(fileStream2);Console.WriteLine($"Downloaded {fileStream2.Length/1024/1024}MB to {fileStream2.Name}");}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.
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.
The project has no special dependencies except to the awesome API from the ServerJars.com website.
