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(@NonNull String username) Constructs a new MinecraftProtocol instance for logging in using offline mode.MinecraftProtocol(@NonNull 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 PacketCodec codec, @NonNull GameProfile profile, String accessToken) Constructs a new MinecraftProtocol instance for logging in.MinecraftProtocol(PacketCodec codec) Constructs a new MinecraftProtocol instance for making status queries. -
Method Summary
Modifier and TypeMethodDescriptionprotected EncryptionConfigcreateEncryption(Key key) Creates a newPacketCodecHelperthat can be used for each session.Authentication access token.getCodec()The codec used for the Minecraft protocol.Gets the packet header of this protocol.Gets the packet registry for this protocol.The player's identity.Gets the prefix used when locating SRV records for this protocol.getState()Gets the currentProtocolStatethe client is in.booleanWhether to add the default client and server listeners for performing initial login.static org.cloudburstmc.nbt.NbtMapvoidnewClientSession(Session session, boolean transferring) 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.voidsetState(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
public MinecraftProtocol(@NonNull @NonNull PacketCodec codec, @NonNull @NonNull GameProfile profile, String accessToken) 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.
-
createHelper
Description copied from class:PacketProtocolCreates a newPacketCodecHelperthat can be used for each session.- Specified by:
createHelperin classPacketProtocol- Returns:
- A new
PacketCodecHelper.
-
newClientSession
Description copied from class:PacketProtocolCalled when a client session is created with this protocol.- Specified by:
newClientSessionin classPacketProtocol- Parameters:
session- The created session.transferring- If the client is being transferred between servers.
-
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.
-
getPacketRegistry
Description copied from class:PacketProtocolGets the packet registry for this protocol.- Specified by:
getPacketRegistryin classPacketProtocol- Returns:
- The protocol's packet registry.
-
createEncryption
-
getState
Gets the currentProtocolStatethe client is in.- Returns:
- The current
ProtocolState.
-
setState
-
loadNetworkCodec
public static org.cloudburstmc.nbt.NbtMap loadNetworkCodec() -
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.
-