MrServer 1.0.0
Additional Details
This library is not tested yet.
dotnet add package MrServer --version 1.0.0
NuGet\Install-Package MrServer -Version 1.0.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="MrServer" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MrServer" Version="1.0.0" />
<PackageReference Include="MrServer" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MrServer --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: MrServer, 1.0.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.
#:package MrServer@1.0.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MrServer&version=1.0.0
#tool nuget:?package=MrServer&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
MrServer - Minecraft Server Pinging Library
A C# .NET 8 library for pinging Minecraft servers and retrieving server information.
Features
- Async/Sync Support: Both asynchronous and synchronous methods available
- Comprehensive Server Info: Retrieve version, player count, description, latency, and more
- Player Sampling: Get a list of online players (when available)
- Timeout Configuration: Configurable connection timeout
- Error Handling: Robust error handling with detailed error messages
- Cross-Platform: Works on Windows, Linux, and macOS
Installation
Add this NuGet package to your project:
dotnet add package Newtonsoft.Json
Usage
Basic Usage
using Mr_Server;
// Create an instance of MrServer
var mrServer = new MrServer();
// Ping a server asynchronously
var serverInfo = await mrServer.PingServerAsync("mc.hypixel.net", 25565);
if (serverInfo.IsOnline)
{
Console.WriteLine($"Server is online!");
Console.WriteLine($"Version: {serverInfo.Version}");
Console.WriteLine($"Players: {serverInfo.OnlinePlayers}/{serverInfo.MaxPlayers}");
Console.WriteLine($"Description: {serverInfo.Description}");
Console.WriteLine($"Latency: {serverInfo.Latency}ms");
}
else
{
Console.WriteLine($"Server is offline: {serverInfo.Description}");
}
Synchronous Usage
var mrServer = new MrServer();
var serverInfo = mrServer.PingServer("localhost", 25565);
Custom Timeout
// Set a 3-second timeout
var mrServer = new MrServer(timeoutMs: 3000);
Multiple Servers
var mrServer = new MrServer();
var servers = new[] { "mc.hypixel.net", "play.cubecraft.net", "mineverse.com" };
var tasks = servers.Select(server => mrServer.PingServerAsync(server));
var results = await Task.WhenAll(tasks);
foreach (var result in results)
{
Console.WriteLine($"Server: {result.IsOnline ? "Online" : "Offline"}");
}
API Reference
MrServer Class
Constructors
MrServer()
- Creates an instance with default 5-second timeoutMrServer(int timeoutMs)
- Creates an instance with custom timeout
Methods
Task<MinecraftServerInfo> PingServerAsync(string hostname, int port = 25565)
MinecraftServerInfo PingServer(string hostname, int port = 25565)
MinecraftServerInfo Class
Properties
string? Version
- Server version (e.g., "1.19.2")string? Protocol
- Protocol version numberint MaxPlayers
- Maximum number of playersint OnlinePlayers
- Current number of online playersstring? Description
- Server description/MOTDstring? Favicon
- Base64 encoded server iconList<PlayerInfo>? Players
- Sample of online playerslong Latency
- Response time in millisecondsbool IsOnline
- Whether the server is reachable
PlayerInfo Class
Properties
string? Name
- Player usernamestring? Id
- Player UUID
Error Handling
The library handles various error conditions:
- Connection Timeout: When the server doesn't respond within the timeout period
- Connection Refused: When the server is not running or port is closed
- Invalid Response: When the server sends malformed data
- Network Errors: General network connectivity issues
When an error occurs, IsOnline
will be false
and Description
will contain the error message.
Protocol Support
This library implements the Minecraft Server List Ping protocol used by modern Minecraft servers (1.7+). It supports:
- Server status requests
- Ping/pong for latency measurement
- JSON response parsing
- Protocol version 760 (1.19.2) by default
Requirements
- .NET 8.0 or later
- Newtonsoft.Json package
License
This project is open source. Feel free to use and modify as needed.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Newtonsoft.Json (>= 13.0.3)
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.0.0 | 137 | 7/15/2025 |