Table of Contents

Class Minecraft

Namespace
OpenGSQ.Protocols
Assembly
OpenGSQ.dll

Minecraft Protocol (https://wiki.vg/Server_List_Ping)

public class Minecraft : ProtocolBase
Inheritance
Minecraft
Inherited Members

Constructors

Minecraft(string, int, int)

Initializes a new instance of the Minecraft class.

public Minecraft(string host, int port, int timeout = 5000)

Parameters

host string

The host.

port int

The port.

timeout int

The timeout. Default is 5000.

Properties

FullName

Gets the full name of the protocol.

public override string FullName { get; }

Property Value

string

Methods

GetStatus(int)

Gets the server status asynchronously.

public Task<Dictionary<string, JsonElement>> GetStatus(int version = 47)

Parameters

version int

The protocol version. Default is 47.

Returns

Task<Dictionary<string, JsonElement>>

A task that represents the asynchronous operation. The task result contains the server status.

Exceptions

TimeoutException

Thrown when the operation times out.

GetStatusPre17()

Gets the server status for servers using a version older than Minecraft 1.7.

public Task<StatusPre17> GetStatusPre17()

Returns

Task<StatusPre17>

A task that represents the asynchronous operation. The task result contains the server status.

Exceptions

InvalidPacketException

Thrown when the packet header does not match the expected header.

TimeoutException

Thrown when the operation times out.

PackVarint(int)

Packs an integer into a Varint.

protected byte[] PackVarint(int val)

Parameters

val int

The integer to pack.

Returns

byte[]

The packed Varint as a byte array.

StripColors(string)

Strips color codes from the input text.

public static string StripColors(string text)

Parameters

text string

The text to strip color codes from.

Returns

string

The text with color codes stripped.

UnpackVarint(BinaryReader)

Unpacks a Varint into an integer.

protected int UnpackVarint(BinaryReader br)

Parameters

br BinaryReader

The BinaryReader to read the Varint from.

Returns

int

The unpacked integer.