Class Minecraft
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
Properties
FullName
Gets the full name of the protocol.
public override string FullName { get; }
Property Value
Methods
GetStatus(int)
Gets the server status asynchronously.
public Task<Dictionary<string, JsonElement>> GetStatus(int version = 47)
Parameters
version
intThe 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
intThe 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
stringThe 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
BinaryReaderThe BinaryReader to read the Varint from.
Returns
- int
The unpacked integer.