Class PlayerLoginEvent


  • public class PlayerLoginEvent
    extends PlayerEvent
    Stores details for players attempting to log in
    • Constructor Detail

      • PlayerLoginEvent

        public PlayerLoginEvent​(Player player,
                                String hostname,
                                InetAddress address,
                                InetAddress realAddress)
        This constructor defaults message to an empty string, and result to ALLOWED
        Parameters:
        player - The Player for this event
        hostname - The hostname that was used to connect to the server
        address - The address the player used to connect, provided for timing issues
      • PlayerLoginEvent

        public PlayerLoginEvent​(Player player,
                                String hostname,
                                InetAddress address,
                                PlayerLoginEvent.Result result,
                                String message,
                                InetAddress realAddress)
        This constructor pre-configures the event with a result and message
        Parameters:
        player - The Player for this event
        hostname - The hostname that was used to connect to the server
        address - The address the player used to connect, provided for timing issues
        result - The result status for this event
        message - The message to be displayed if result denies login
    • Method Detail

      • getRealAddress

        public InetAddress getRealAddress()
        Gets the connection address of this player, regardless of whether it has been spoofed or not.
        Returns:
        the player's connection address
      • getResult

        public PlayerLoginEvent.Result getResult()
        Gets the current result of the login, as an enum
        Returns:
        Current Result of the login
      • setResult

        public void setResult​(PlayerLoginEvent.Result result)
        Sets the new result of the login, as an enum
        Parameters:
        result - New result to set
      • getKickMessage

        public String getKickMessage()
        Gets the current kick message that will be used if getResult() != Result.ALLOWED
        Returns:
        Current kick message
      • setKickMessage

        public void setKickMessage​(String message)
        Sets the kick message to display if getResult() != Result.ALLOWED
        Parameters:
        message - New kick message
      • getHostname

        public String getHostname()
        Gets the hostname that the player used to connect to the server, or blank if unknown
        Returns:
        The hostname
      • allow

        public void allow()
        Allows the player to log in
      • disallow

        public void disallow​(PlayerLoginEvent.Result result,
                             String message)
        Disallows the player from logging in, with the given reason
        Parameters:
        result - New result for disallowing the player
        message - Kick message to display to the user
      • getAddress

        public InetAddress getAddress()
        Gets the InetAddress for the Player associated with this event. This method is provided as a workaround for player.getAddress() returning null during PlayerLoginEvent.
        Returns:
        The address for this player. For legacy compatibility, this may be null.
      • getHandlerList

        public static HandlerList getHandlerList()