Class MinecraftProtocol
java.lang.Object
org.geysermc.mcprotocollib.network.packet.PacketProtocol
org.geysermc.mcprotocollib.protocol.MinecraftProtocol
Implements the Minecraft protocol.
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new MinecraftProtocol instance for making status queries.MinecraftProtocol(String username) Constructs a new MinecraftProtocol instance for logging in using offline mode.MinecraftProtocol(GameProfile profile, @Nullable String accessToken) Constructs a new MinecraftProtocol instance for logging in.MinecraftProtocol(PacketCodec codec) Constructs a new MinecraftProtocol instance for making status queries.MinecraftProtocol(PacketCodec codec, String username) Constructs a new MinecraftProtocol instance for logging in using offline mode.MinecraftProtocol(PacketCodec codec, GameProfile profile, @Nullable String accessToken) Constructs a new MinecraftProtocol instance for logging in. -
Method Summary
Modifier and TypeMethodDescriptionprotected EncryptionConfigcreateEncryption(Key key) @Nullable StringAuthentication access token.getCodec()The codec used for the Minecraft protocol.Gets the inbound packet registry for this protocol.@Nullable ProtocolStateGets the current inboundProtocolStatewe're in.Gets the outbound packet registry for this protocol.@Nullable ProtocolStateGets the current outboundProtocolStatewe're in.Gets the packet header of this protocol.@Nullable GameProfileThe player's identity.Gets the prefix used when locating SRV records for this protocol.booleanWhether to add the default client and server listeners for performing initial login.static org.cloudburstmc.nbt.NbtMapstatic org.cloudburstmc.nbt.NbtMapvoidnewClientSession(Session session) Called when a client session is created with this protocol.voidnewServerSession(Server server, Session session) Called when a server session is created with this protocol.voidResets the protocol states toProtocolState.HANDSHAKE.voidsetInboundState(ProtocolState state) voidsetOutboundState(ProtocolState state) voidsetUseDefaultListeners(boolean useDefaultListeners) Whether to add the default client and server listeners for performing initial login.
-
Constructor Details
-
MinecraftProtocol
public MinecraftProtocol()Constructs a new MinecraftProtocol instance for making status queries. -
MinecraftProtocol
Constructs a new MinecraftProtocol instance for making status queries.- Parameters:
codec- The packet codec to use.
-
MinecraftProtocol
Constructs a new MinecraftProtocol instance for logging in using offline mode.- Parameters:
username- Username to use.
-
MinecraftProtocol
Constructs a new MinecraftProtocol instance for logging in using offline mode.- Parameters:
codec- The packet codec to use.username- Username to use.
-
MinecraftProtocol
Constructs a new MinecraftProtocol instance for logging in.- Parameters:
profile- GameProfile to use.accessToken- Access token to use, or null if using offline mode.
-
MinecraftProtocol
Constructs a new MinecraftProtocol instance for logging in.- Parameters:
codec- The packet codec to use.profile- GameProfile to use.accessToken- Access token to use, or null if using offline mode.
-
-
Method Details
-
getSRVRecordPrefix
Description copied from class:PacketProtocolGets the prefix used when locating SRV records for this protocol.- Specified by:
getSRVRecordPrefixin classPacketProtocol- Returns:
- The protocol's SRV record prefix.
-
getPacketHeader
Description copied from class:PacketProtocolGets the packet header of this protocol.- Specified by:
getPacketHeaderin classPacketProtocol- Returns:
- The protocol's packet header.
-
newClientSession
Description copied from class:PacketProtocolCalled when a client session is created with this protocol.- Specified by:
newClientSessionin classPacketProtocol- Parameters:
session- The created session.
-
newServerSession
Description copied from class:PacketProtocolCalled when a server session is created with this protocol.- Specified by:
newServerSessionin classPacketProtocol- Parameters:
server- The server that the session belongs to.session- The created session.
-
getInboundPacketRegistry
Description copied from class:PacketProtocolGets the inbound packet registry for this protocol.- Specified by:
getInboundPacketRegistryin classPacketProtocol- Returns:
- The protocol's inbound packet registry.
-
getOutboundPacketRegistry
Description copied from class:PacketProtocolGets the outbound packet registry for this protocol.- Specified by:
getOutboundPacketRegistryin classPacketProtocol- Returns:
- The protocol's outbound packet registry.
-
createEncryption
-
resetStates
public void resetStates()Resets the protocol states toProtocolState.HANDSHAKE. -
getInboundState
Gets the current inboundProtocolStatewe're in.- Returns:
- The current inbound
ProtocolState.
-
getOutboundState
Gets the current outboundProtocolStatewe're in.- Returns:
- The current outbound
ProtocolState.
-
setInboundState
-
setOutboundState
-
loadNetworkCodec
public static org.cloudburstmc.nbt.NbtMap loadNetworkCodec() -
loadNetworkTags
public static org.cloudburstmc.nbt.NbtMap loadNetworkTags() -
getCodec
The codec used for the Minecraft protocol. -
getProfile
The player's identity. -
getAccessToken
Authentication access token. -
isUseDefaultListeners
public boolean isUseDefaultListeners()Whether to add the default client and server listeners for performing initial login. -
setUseDefaultListeners
public void setUseDefaultListeners(boolean useDefaultListeners) Whether to add the default client and server listeners for performing initial login.
-