类 PlayerLoginEvent


public class PlayerLoginEvent extends PlayerEvent
玩家尝试登录的事件.
请注意本事件在玩家初始化的早期阶段被触发. 建议与玩家实体有关的大部分选项在PlayerJoinEvent后应用.
  • 构造器详细资料

  • 方法详细资料

    • getRealAddress

      @NotNull public @NotNull InetAddress getRealAddress()
      获取玩家的连接地址, 无论地址的真实与否.

      原文:Gets the connection address of this player, regardless of whether it has been spoofed or not.

      返回:
      玩家的连接地址
    • getResult

      获取当前的登录状态.

      原文:Gets the current result of the login, as an enum

      返回:
      登录状态
    • setResult

      public void setResult(@NotNull @NotNull PlayerLoginEvent.Result result)
      设置登录的状态.

      原文:Sets the new result of the login, as an enum

      参数:
      result - 登录状态
    • getKickMessage

      @NotNull public @NotNull String getKickMessage()
      如果getResult() != Result.ALLOWED,获取将使用的踢出消息

      原文:Gets the current kick message that will be used if getResult() != Result.ALLOWED

      返回:
      踢出消息
    • setKickMessage

      public void setKickMessage(@NotNull @NotNull String message)
      如果getResult() != Result.ALLOWED,设置要显示的踢出消息

      原文:Sets the kick message to display if getResult() != Result.ALLOWED

      参数:
      message - 踢出消息
    • getHostname

      @NotNull public @NotNull String getHostname()
      获取玩家用于连接服务器的主机名,如果未知则为空

      原文:Gets the hostname that the player used to connect to the server, or blank if unknown

      返回:
      主机名
    • allow

      public void allow()
      允许玩家登录

      原文:Allows the player to log in

    • disallow

      public void disallow(@NotNull @NotNull PlayerLoginEvent.Result result, @NotNull @NotNull String message)
      以给定的理由不允许玩家登录

      原文:Disallows the player from logging in, with the given reason

      参数:
      result - 不允许玩家登录的理由
      message - 给用户显示的踢出消息
    • getAddress

      @NotNull public @NotNull InetAddress getAddress()
      获取玩家的IP地址. 这个方法是在此事件期间使用 player.getAddress() 为null的解决办法

      原文:Gets the InetAddress for the Player associated with this event. This method is provided as a workaround for player.getAddress() returning null during PlayerLoginEvent.

      返回:
      玩家的IP地址。为兼容旧版,这可能是null
    • getHandlers

      @NotNull public @NotNull HandlerList getHandlers()
      指定者:
      getHandlers 在类中 Event
    • getHandlerList

      @NotNull public static @NotNull HandlerList getHandlerList()