Class ServerLoginNetworkHandler

java.lang.Object
net.minecraft.server.network.ServerLoginNetworkHandler
All Implemented Interfaces:
PacketListener, ServerLoginPacketListener

public class ServerLoginNetworkHandler
extends Object
implements ServerLoginPacketListener
The server login network handler.

It listens to packets on the netty event loop and is ticked on the server thread simultaneously.

  • Field Details

    • NEXT_AUTHENTICATOR_THREAD_ID

      private static final AtomicInteger NEXT_AUTHENTICATOR_THREAD_ID
    • LOGGER

      private static final Logger LOGGER
    • RANDOM

      private static final Random RANDOM
    • nonce

      private final byte[] nonce
    • server

      private final MinecraftServer server
    • connection

      public final ClientConnection connection
    • state

    • loginTicks

      private int loginTicks
    • profile

      private com.mojang.authlib.GameProfile profile
    • serverId

      private final String serverId
      See Also:
      Constant Field Values
    • secretKey

      private SecretKey secretKey
    • delayedPlayer

      private ServerPlayerEntity delayedPlayer
      The delayed player, waiting to join the server once the existing player with the same UUID is gone.

      This will only be non-null if the state is delay-accept, and is reset to null once the player is accepted.

  • Constructor Details

  • Method Details

    • tick

      public void tick()
      Ticks this login network handler.

      This accepts the player to the server if ready. If the state is delay accept, it checks if the old player with the same UUID is gone and admits the player.

    • getConnection

      public ClientConnection getConnection()
      Returns the connection this packet listener intends to listen to.
      Specified by:
      getConnection in interface PacketListener
      See Also:
      ClientConnection.getPacketListener()
    • disconnect

      public void disconnect​(Text reason)
    • acceptPlayer

      public void acceptPlayer()
      Creates the player to be added to the server and adds it to the server.

      If a player with the same UUID is in the world, it will create the player and transition to the delay accept state.

    • onDisconnected

      public void onDisconnected​(Text reason)
      Called when the connection this listener listens to has disconnected. Can be used to display the disconnection reason.
      Specified by:
      onDisconnected in interface PacketListener
      Parameters:
      reason - the reason of disconnection; may be a generic message
    • getConnectionInfo

      public String getConnectionInfo()
    • onHello

      public void onHello​(LoginHelloC2SPacket packet)
      Specified by:
      onHello in interface ServerLoginPacketListener
    • onKey

      public void onKey​(LoginKeyC2SPacket packet)
      Specified by:
      onKey in interface ServerLoginPacketListener
    • onQueryResponse

      public void onQueryResponse​(LoginQueryResponseC2SPacket packet)
      Specified by:
      onQueryResponse in interface ServerLoginPacketListener
    • toOfflineProfile

      protected com.mojang.authlib.GameProfile toOfflineProfile​(com.mojang.authlib.GameProfile profile)