Package us.donut.mmc
Class Client
- java.lang.Object
-
- us.donut.mmc.Client
-
public class Client extends Object
A minimal Minecraft client implementation which provides methods for server list pings, logins, and sending/receiving packets. Packet encryption and compression is handled automatically.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classClient.ClientInputStreamData from a server.static classClient.ClientOutputStreamData going to a server.
-
Constructor Summary
Constructors Constructor Description Client()Constructs a new client.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddisconnect()Disconnects this client if currently connected to a server.booleanisConnected()Checks if this client is connected to a server.InboundPacketlogin(Account account, String address, int port)Executes the login process.InboundPacketping(String address, int port)Executes a server list ping.InboundPacketreceive()Reads a packet from the connected server (blocks until a packet is received).voidsend(OutboundPacket packet)Sends a packet to the connected server.
-
-
-
Method Detail
-
disconnect
public void disconnect() throws IOExceptionDisconnects this client if currently connected to a server.- Throws:
IOException
-
isConnected
public boolean isConnected()
Checks if this client is connected to a server.- Returns:
- true if the client is connected to a server.
-
send
public void send(OutboundPacket packet) throws IOException
Sends a packet to the connected server. Packet encryption and compression is handled automatically. This method is thread safe.- Parameters:
packet- the packet to send- Throws:
IOException
-
receive
public InboundPacket receive() throws IOException, DataFormatException
Reads a packet from the connected server (blocks until a packet is received). Packet encryption and compression is handled automatically.- Returns:
- the packet from the server
- Throws:
IOExceptionDataFormatException
-
ping
public InboundPacket ping(String address, int port) throws IOException, DataFormatException
Executes a server list ping.- Parameters:
address- the server address (IP or hostname)port- the server port- Returns:
- a status response packet if successful
- Throws:
IOExceptionDataFormatException
-
login
public InboundPacket login(Account account, String address, int port) throws IOException, GeneralSecurityException, InterruptedException, DataFormatException
Executes the login process.- Parameters:
account- the account with which to loginaddress- the server address (IP or hostname)port- the server port- Returns:
- a login success packet if successful
- Throws:
IOExceptionGeneralSecurityExceptionInterruptedExceptionDataFormatException
-
-