Package org.geysermc.geyser.session
Class GeyserSession
java.lang.Object
org.geysermc.geyser.session.GeyserSession
- All Implemented Interfaces:
org.geysermc.api.session.Connection,GeyserConnection,CommandSender
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionGeyserSession(GeyserImpl geyser, com.nukkitx.protocol.bedrock.BedrockServerSession bedrockServerSession, io.netty.channel.EventLoop eventLoop) -
Method Summary
Modifier and TypeMethodDescriptionvoidStarts ticking the amount of time that the Bedrock client has been swinging their arm, and disables blocking if blocking.com.nukkitx.protocol.bedrock.data.AttributeDataAdjusts speed if the player is crawling.voidauthenticate(String username)voidauthenticate(String username, String password)voidvoidauthenticateWithMicrosoftCode(boolean offlineAccess)Present a form window to the user asking to log in with another web browservoidauthenticateWithRefreshToken(String refreshToken)booleanvoidconfirmTeleport(com.nukkitx.math.vector.Vector3d position)voidconnect()Send all necessary packets to load Bedrock into the serverprotected voidWill be overwritten for GeyserConnect.voiddisconnect(String reason)voidexecuteInEventLoop(Runnable runnable)Executes a task and prints a stack trace if an error occurs.com.github.steveice10.mc.protocol.codec.MinecraftCodecHelperReturns the locale of the command sender.intintbooleanhasPermission(String permission)Checks if the given session's player has a permissionbooleanname()booleanIf successful, also begins connecting to the Java server.voidplaySoundEvent(com.nukkitx.protocol.bedrock.data.SoundEvent sound, com.nukkitx.math.vector.Vector3f position)voidrefreshEmotes(List<UUID> emotes)voidRemoves the following fog IDs from the client and the cache.scheduleInEventLoop(Runnable runnable, long duration, TimeUnit timeUnit)Schedules a task and prints a stack trace if an error occurs.voidSend an AdventureSettingsPacket to the client with the latest flagsvoidSends a chat message to the Java server.voidsendCommand(String command)Sends a command to the Java server.voidsendDownstreamPacket(com.github.steveice10.packetlib.packet.Packet packet)Send a packet to the remote server.voidSend the following fog IDs, as well as the cached ones, to the client.voidsendForm(org.geysermc.cumulus.form.Form form)voidsendForm(org.geysermc.cumulus.form.util.FormBuilder<?,?,?> formBuilder)voidsendForm(org.geysermc.cumulus.Form<?> form)Deprecated.since Cumulus version 1.1, and will be removed when Cumulus 2.0 releases.voidsendForm(org.geysermc.cumulus.util.FormBuilder<?,?> formBuilder)Deprecated.since Cumulus version 1.1, and will be removed when Cumulus 2.0 releases.voidsendGameRule(String gameRule, Object value)Send a gamerule value to the clientvoidSend a packet to the server to indicate client render distance, locale, skin parts, and hand preference.voidsendMessage(String message)voidsendUpstreamPacket(com.nukkitx.protocol.bedrock.BedrockPacket packet)Queue a packet to be sent to player.voidsendUpstreamPacketImmediately(com.nukkitx.protocol.bedrock.BedrockPacket packet)Send a packet immediately to the player.voidsetAuthenticationData(AuthData authData)voidsetDaylightCycle(boolean doCycle)Changes the daylight cycle gamerule on the client This is used in the login screen along-side normal usagevoidsetFlying(boolean flying)voidsetReducedDebugInfo(boolean value)Update the cached value for the reduced debug info gamerule.voidsetServerRenderDistance(int renderDistance)voidsetSwimming(boolean swimming)voidvoidprotected voidtick()Called every 50 milliseconds - one Minecraft tick.booleantransfer(@NonNull String address, @org.checkerframework.common.value.qual.IntRange(from=0L, to=65535L) int port)voidupdateStatistics(@NonNull Map<com.github.steveice10.mc.protocol.data.game.statistic.Statistic,Integer> statistics)Used for updating statistic values since we only get changes from the serveruuid()xuid()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.geysermc.geyser.command.CommandSender
sendMessage
-
Field Details
-
sentSpawnPacket
protected boolean sentSpawnPacket
-
-
Constructor Details
-
GeyserSession
public GeyserSession(GeyserImpl geyser, com.nukkitx.protocol.bedrock.BedrockServerSession bedrockServerSession, io.netty.channel.EventLoop eventLoop)
-
-
Method Details
-
connect
public void connect()Send all necessary packets to load Bedrock into the server -
authenticate
-
authenticate
-
authenticateWithRefreshToken
-
authenticateWithMicrosoftCode
public void authenticateWithMicrosoftCode() -
authenticateWithMicrosoftCode
public void authenticateWithMicrosoftCode(boolean offlineAccess)Present a form window to the user asking to log in with another web browser -
onMicrosoftLoginComplete
If successful, also begins connecting to the Java server. -
disconnect
-
executeInEventLoop
Executes a task and prints a stack trace if an error occurs. -
scheduleInEventLoop
Schedules a task and prints a stack trace if an error occurs. -
tick
protected void tick()Called every 50 milliseconds - one Minecraft tick. -
setAuthenticationData
-
startSneaking
public void startSneaking() -
stopSneaking
public void stopSneaking() -
setSwimming
public void setSwimming(boolean swimming) -
setFlying
public void setFlying(boolean flying) -
adjustSpeed
public com.nukkitx.protocol.bedrock.data.AttributeData adjustSpeed()Adjusts speed if the player is crawling.- Returns:
- not null if attributes should be updated.
-
activateArmAnimationTicking
public void activateArmAnimationTicking()Starts ticking the amount of time that the Bedrock client has been swinging their arm, and disables blocking if blocking. -
disableSrvResolving
protected void disableSrvResolving()Will be overwritten for GeyserConnect. -
name
- Specified by:
namein interfaceCommandSender- Specified by:
namein interfaceorg.geysermc.api.session.Connection
-
uuid
- Specified by:
uuidin interfaceorg.geysermc.api.session.Connection
-
xuid
- Specified by:
xuidin interfaceorg.geysermc.api.session.Connection
-
transfer
public boolean transfer(@NonNull @NonNull String address, @org.checkerframework.common.value.qual.IntRange(from=0L, to=65535L) int port)- Specified by:
transferin interfaceorg.geysermc.api.session.Connection
-
sendMessage
- Specified by:
sendMessagein interfaceCommandSender
-
isConsole
public boolean isConsole()- Specified by:
isConsolein interfaceCommandSender- Returns:
- true if the specified sender is from the console.
-
getLocale
Description copied from interface:CommandSenderReturns the locale of the command sender. Defaults to the default locale atGeyserLocale.getDefaultLocale().- Specified by:
getLocalein interfaceCommandSender- Returns:
- the locale of the command sender.
-
sendChat
Sends a chat message to the Java server. -
sendCommand
Sends a command to the Java server. -
setServerRenderDistance
public void setServerRenderDistance(int renderDistance) -
getSocketAddress
-
sendForm
public void sendForm(org.geysermc.cumulus.form.Form form) -
sendForm
public void sendForm(org.geysermc.cumulus.form.util.FormBuilder<?,?,?> formBuilder) -
sendForm
Deprecated.since Cumulus version 1.1, and will be removed when Cumulus 2.0 releases. Please use the new forms instead. -
sendForm
Deprecated.since Cumulus version 1.1, and will be removed when Cumulus 2.0 releases. Please use the new forms instead. -
getNextItemNetId
public int getNextItemNetId()- Returns:
- the next Bedrock item network ID to use for a new item
-
confirmTeleport
public void confirmTeleport(com.nukkitx.math.vector.Vector3d position) -
sendUpstreamPacket
public void sendUpstreamPacket(com.nukkitx.protocol.bedrock.BedrockPacket packet)Queue a packet to be sent to player.- Parameters:
packet- the bedrock packet from the NukkitX protocol lib
-
sendUpstreamPacketImmediately
public void sendUpstreamPacketImmediately(com.nukkitx.protocol.bedrock.BedrockPacket packet)Send a packet immediately to the player.- Parameters:
packet- the bedrock packet from the NukkitX protocol lib
-
sendDownstreamPacket
public void sendDownstreamPacket(com.github.steveice10.packetlib.packet.Packet packet)Send a packet to the remote server.- Parameters:
packet- the java edition packet from MCProtocolLib
-
setReducedDebugInfo
public void setReducedDebugInfo(boolean value)Update the cached value for the reduced debug info gamerule. If enabled, also hides the player's coordinates.- Parameters:
value- The new value for reducedDebugInfo
-
setDaylightCycle
public void setDaylightCycle(boolean doCycle)Changes the daylight cycle gamerule on the client This is used in the login screen along-side normal usage- Parameters:
doCycle- If the cycle should continue
-
sendGameRule
Send a gamerule value to the client- Parameters:
gameRule- The gamerule to sendvalue- The value of the gamerule
-
hasPermission
Checks if the given session's player has a permission- Specified by:
hasPermissionin interfaceCommandSender- Parameters:
permission- The permission node to check- Returns:
- true if the player has the requested permission, false if not
-
sendAdventureSettings
public void sendAdventureSettings()Send an AdventureSettingsPacket to the client with the latest flags -
sendJavaClientSettings
public void sendJavaClientSettings()Send a packet to the server to indicate client render distance, locale, skin parts, and hand preference. -
getNextSequence
public int getNextSequence() -
updateStatistics
public void updateStatistics(@NonNull @NonNull Map<com.github.steveice10.mc.protocol.data.game.statistic.Statistic,Integer> statistics)Used for updating statistic values since we only get changes from the server- Parameters:
statistics- Updated statistics values
-
refreshEmotes
-
sendFog
Send the following fog IDs, as well as the cached ones, to the client. Fog IDs can be found here: https://wiki.bedrock.dev/documentation/fog-ids.html- Parameters:
fogNameSpaces- the fog ids to add
-
removeFog
Removes the following fog IDs from the client and the cache.- Parameters:
fogNameSpaces- the fog ids to remove
-
canUseCommandBlocks
public boolean canUseCommandBlocks() -
playSoundEvent
public void playSoundEvent(com.nukkitx.protocol.bedrock.data.SoundEvent sound, com.nukkitx.math.vector.Vector3f position) -
getCodecHelper
public com.github.steveice10.mc.protocol.codec.MinecraftCodecHelper getCodecHelper()
-