Discussion in 'Bukkit Preview' started by SpaceManiac, Mar 9, 2012.

  1. Offline


    Among the suite of additions in Minecraft 1.2 is a protocol change in which the client, in the handshake packet (the first it sends to the server) specifies the username it is planning on logging in with and the address and port it used to connect to the server. This string takes the form "host:nport" (including the port even if the player did not specify it directly, in which case it defaults to 25565), and can be retrieved from a PlayerLoginEvent via getHostname().

    There's many interesting things that can be done with the host and port information, e.g. send a player to a different world based on what hostname they connect with, or perhaps give a player some special bonus if they connect with a specific hostname or port.

    Technical Details
    Specifically, Packet2Handshake has a string field 'a' in the form "username;host:nport" e.g. "SpaceManiac;localhost:25565". The former half is not useful during PlayerLoginEvent since the username is already known as part of the login, but the latter can be stored in NetLoginHandler during the login process and then passed to ServerConfigurationManager.attemptLogin, where PlayerLoginEvent is called.

Share This Page