Class GeyserSession

java.lang.Object
org.geysermc.geyser.session.GeyserSession
All Implemented Interfaces:
org.geysermc.api.session.Connection, GeyserConnection, CommandSender

public class GeyserSession extends Object implements GeyserConnection, CommandSender
  • 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
    • login

      public void login()
    • authenticate

      public void authenticate(String username)
    • authenticate

      public void authenticate(String username, String password)
    • authenticateWithRefreshToken

      public void authenticateWithRefreshToken(String refreshToken)
    • 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

      public boolean onMicrosoftLoginComplete(PendingMicrosoftAuthentication.AuthenticationTask task)
      If successful, also begins connecting to the Java server.
    • disconnect

      public void disconnect(String reason)
    • close

      public void close()
    • executeInEventLoop

      public void executeInEventLoop(Runnable runnable)
      Executes a task and prints a stack trace if an error occurs.
    • scheduleInEventLoop

      public ScheduledFuture<?> scheduleInEventLoop(Runnable runnable, long duration, TimeUnit timeUnit)
      Schedules a task and prints a stack trace if an error occurs.
    • tick

      protected void tick()
      Called every 50 milliseconds - one Minecraft tick.
    • setAuthenticationData

      public void setAuthenticationData(AuthData authData)
    • 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

      public String name()
      Specified by:
      name in interface CommandSender
      Specified by:
      name in interface org.geysermc.api.session.Connection
    • uuid

      public UUID uuid()
      Specified by:
      uuid in interface org.geysermc.api.session.Connection
    • xuid

      public String xuid()
      Specified by:
      xuid in interface org.geysermc.api.session.Connection
    • sendMessage

      public void sendMessage(String message)
      Specified by:
      sendMessage in interface CommandSender
    • isConsole

      public boolean isConsole()
      Specified by:
      isConsole in interface CommandSender
      Returns:
      true if the specified sender is from the console.
    • getLocale

      public String getLocale()
      Description copied from interface: CommandSender
      Returns the locale of the command sender. Defaults to the default locale at GeyserLocale.getDefaultLocale().
      Specified by:
      getLocale in interface CommandSender
      Returns:
      the locale of the command sender.
    • setServerRenderDistance

      public void setServerRenderDistance(int renderDistance)
    • getSocketAddress

      public InetSocketAddress getSocketAddress()
    • sendForm

      public void sendForm(org.geysermc.cumulus.Form form)
    • sendForm

      public void sendForm(org.geysermc.cumulus.util.FormBuilder<?,​?> formBuilder)
    • 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

      public void sendGameRule(String gameRule, Object value)
      Send a gamerule value to the client
      Parameters:
      gameRule - The gamerule to send
      value - The value of the gamerule
    • hasPermission

      public boolean hasPermission(String permission)
      Checks if the given session's player has a permission
      Specified by:
      hasPermission in interface CommandSender
      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.
    • 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

      public void refreshEmotes(List<UUID> emotes)
    • sendFog

      public void sendFog(String... fogNameSpaces)
      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

      public void removeFog(String... fogNameSpaces)
      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)