public class MinecraftProtocol extends PacketProtocol
| Constructor and Description |
|---|
MinecraftProtocol()
Constructs a new MinecraftProtocol instance for making status queries.
|
MinecraftProtocol(@NonNull com.github.steveice10.mc.auth.data.GameProfile profile,
String accessToken)
Constructs a new MinecraftProtocol instance for logging in.
|
MinecraftProtocol(PacketCodec codec)
Constructs a new MinecraftProtocol instance for making status queries.
|
MinecraftProtocol(@NonNull PacketCodec codec,
@NonNull com.github.steveice10.mc.auth.data.GameProfile profile,
String accessToken)
Constructs a new MinecraftProtocol instance for logging in.
|
MinecraftProtocol(@NonNull PacketCodec codec,
@NonNull String username)
Constructs a new MinecraftProtocol instance for logging in using offline mode.
|
MinecraftProtocol(@NonNull String username)
Constructs a new MinecraftProtocol instance for logging in using offline mode.
|
| Modifier and Type | Method and Description |
|---|---|
Packet |
createClientboundPacket(int id,
io.netty.buffer.ByteBuf buf,
PacketCodecHelper codecHelper)
Creates a new instance of a clientbound packet with the given id and read the clientbound input.
|
MinecraftCodecHelper |
createHelper()
Creates a new
PacketCodecHelper that can be used
for each session. |
Packet |
createServerboundPacket(int id,
io.netty.buffer.ByteBuf buf,
PacketCodecHelper codecHelper)
Creates a new instance of a serverbound packet with the given id and read the serverbound input.
|
Class<? extends Packet> |
getClientboundClass(int id)
Gets the packet class for a packet id.
|
PacketDefinition<?,?> |
getClientboundDefinition(int id)
Gets the clientbound packet definition for the given packet id.
|
int |
getClientboundId(Class<? extends Packet> packetClass)
Gets the registered id of a clientbound packet class.
|
int |
getClientboundId(Packet packet)
Gets the registered id of a clientbound
Packet instance. |
PacketHeader |
getPacketHeader()
Gets the packet header of this protocol.
|
Class<? extends Packet> |
getServerboundClass(int id)
Gets the packet class for a packet id.
|
PacketDefinition<?,?> |
getServerboundDefinition(int id)
Gets the serverbound packet definition for the given packet id.
|
int |
getServerboundId(Class<? extends Packet> packetClass)
Gets the registered id of a serverbound packet class.
|
int |
getServerboundId(Packet packet)
Gets the registered id of a serverbound
Packet instance. |
String |
getSRVRecordPrefix()
Gets the prefix used when locating SRV records for this protocol.
|
ProtocolState |
getState()
Gets the current
ProtocolState the client is in. |
static com.github.steveice10.opennbt.tag.builtin.CompoundTag |
loadNetworkCodec() |
void |
newClientSession(Session session)
Called when a client session is created with this protocol.
|
void |
newServerSession(Server server,
Session session)
Called when a server session is created with this protocol.
|
void |
setState(ProtocolState state) |
clearPackets, register, register, registerClientbound, registerClientbound, registerServerbound, registerServerboundpublic MinecraftProtocol()
public MinecraftProtocol(PacketCodec codec)
codec - The packet codec to use.public MinecraftProtocol(@NonNull
@NonNull String username)
username - Username to use.public MinecraftProtocol(@NonNull
@NonNull PacketCodec codec,
@NonNull
@NonNull String username)
codec - The packet codec to use.username - Username to use.public MinecraftProtocol(@NonNull
@NonNull com.github.steveice10.mc.auth.data.GameProfile profile,
String accessToken)
profile - GameProfile to use.accessToken - Access token to use, or null if using offline mode.public MinecraftProtocol(@NonNull
@NonNull PacketCodec codec,
@NonNull
@NonNull com.github.steveice10.mc.auth.data.GameProfile profile,
String accessToken)
codec - The packet codec to use.profile - GameProfile to use.accessToken - Access token to use, or null if using offline mode.public String getSRVRecordPrefix()
PacketProtocolgetSRVRecordPrefix in class PacketProtocolpublic PacketHeader getPacketHeader()
PacketProtocolgetPacketHeader in class PacketProtocolpublic MinecraftCodecHelper createHelper()
PacketProtocolPacketCodecHelper that can be used
for each session.createHelper in class PacketProtocolPacketCodecHelper.public void newClientSession(Session session)
PacketProtocolnewClientSession in class PacketProtocolsession - The created session.public void newServerSession(Server server, Session session)
PacketProtocolnewServerSession in class PacketProtocolserver - The server that the session belongs to.session - The created session.public ProtocolState getState()
ProtocolState the client is in.ProtocolState.public void setState(ProtocolState state)
public Packet createClientboundPacket(int id, io.netty.buffer.ByteBuf buf, PacketCodecHelper codecHelper) throws IOException
PacketProtocolcreateClientboundPacket in class PacketProtocolid - Id of the packet to create.buf - The buffer to read the packet from.codecHelper - The codec helper.IOException - if there was an IO error whilst reading the packet.public int getClientboundId(Class<? extends Packet> packetClass)
PacketProtocolgetClientboundId in class PacketProtocolpacketClass - Class of the packet to get the id for.public int getClientboundId(Packet packet)
PacketProtocolPacket instance.getClientboundId in class PacketProtocolpacket - Instance of Packet to get the id for.public Class<? extends Packet> getClientboundClass(int id)
PacketProtocolgetClientboundClass in class PacketProtocolid - The packet id.public Packet createServerboundPacket(int id, io.netty.buffer.ByteBuf buf, PacketCodecHelper codecHelper) throws IOException
PacketProtocolcreateServerboundPacket in class PacketProtocolid - Id of the packet to create.buf - The buffer to read the packet from.codecHelper - The codec helper.IOException - if there was an IO error whilst reading the packet.public int getServerboundId(Class<? extends Packet> packetClass)
PacketProtocolgetServerboundId in class PacketProtocolpacketClass - Class of the packet to get the id for.public int getServerboundId(Packet packet)
PacketProtocolPacket instance.getServerboundId in class PacketProtocolpacket - Instance of Packet to get the id for.public Class<? extends Packet> getServerboundClass(int id)
PacketProtocolgetServerboundClass in class PacketProtocolid - The packet id.public PacketDefinition<?,?> getServerboundDefinition(int id)
PacketProtocolgetServerboundDefinition in class PacketProtocolid - The packet id.public PacketDefinition<?,?> getClientboundDefinition(int id)
PacketProtocolgetClientboundDefinition in class PacketProtocolid - The packet id.public static com.github.steveice10.opennbt.tag.builtin.CompoundTag loadNetworkCodec()
Copyright © 2023. All rights reserved.