Package cn.nukkit

Class OfflinePlayer

java.lang.Object
cn.nukkit.OfflinePlayer
All Implemented Interfaces:
IPlayer, Metadatable, ServerOperator

public class OfflinePlayer extends Object implements IPlayer
描述一个不在线的玩家的类。
Describes an offline player.
Since:
Nukkit 1.0 | Nukkit API 1.0.0
Author:
MagicDroidX(code) @ Nukkit Project, 粉鞋大妈(javadoc) @ Nukkit Project
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    OfflinePlayer(Server server, String name)
     
    OfflinePlayer(Server server, UUID uuid)
    初始化这个OfflinePlayer对象。
    Initializes the object OfflinePlayer.
    OfflinePlayer(Server server, UUID uuid, String name)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    得到这个玩家第一次游戏的时间。
    Returns the time this player first played in this server.
    得到这个玩家上次加入游戏的时间。
    Returns the time this player last joined in this server.
    getMetadata(String metadataKey)
     
    返回这个玩家的名称。
    Returns the name of this player.
    得到这个接口的Player对象。
    Returns a Player object for this interface.
    返回玩家所在的服务器。
    Returns the server carrying this player.
     
    boolean
    hasMetadata(String metadataKey)
     
    boolean
    返回这个玩家以前是否来过服务器。
    Returns if this player has played in this server before.
    boolean
    返回这个玩家是否被封禁(ban)。
    Returns if this player is banned.
    boolean
    返回这个玩家是否在线。
    Returns if this player is online.
    boolean
    返回这个对象是不是服务器管理员。
    Returns if this object is an operator.
    boolean
    返回这个玩家是否已加入白名单。
    Returns if this player is pardoned by whitelist.
    void
    removeMetadata(String metadataKey, Plugin owningPlugin)
     
    void
    setBanned(boolean value)
    设置这个玩家是否被封禁(ban)。
    Sets this player to be banned or to be pardoned.
    void
    setMetadata(String metadataKey, MetadataValue newMetadataValue)
     
    void
    setOp(boolean value)
    把这个对象设置成服务器管理员。
    Sets this object to be an operator or not to be.
    void
    setWhitelisted(boolean value)
    把这个玩家加入白名单,或者取消这个玩家的白名单。
    Adds this player to the white list, or removes it from the whitelist.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • OfflinePlayer

      public OfflinePlayer(Server server, UUID uuid)
      初始化这个OfflinePlayer对象。
      Initializes the object OfflinePlayer.
      Parameters:
      server - 这个玩家所在服务器的Server对象。
      The server this player is in, as a Server object.
      uuid - 这个玩家的UUID。
      UUID of this player.
      Since:
      Nukkit 1.0 | Nukkit API 1.0.0
    • OfflinePlayer

      public OfflinePlayer(Server server, String name)
    • OfflinePlayer

      public OfflinePlayer(Server server, UUID uuid, String name)
  • Method Details

    • isOnline

      public boolean isOnline()
      Description copied from interface: IPlayer
      返回这个玩家是否在线。
      Returns if this player is online.
      Specified by:
      isOnline in interface IPlayer
      Returns:
      这个玩家是否在线。
      If this player is online.
    • getName

      public String getName()
      Description copied from interface: IPlayer
      返回这个玩家的名称。
      Returns the name of this player.

      如果是在线的玩家,这个函数只会返回登录名字。如果要返回显示的名字,参见Player.getDisplayName()
      Notice that this will only return its login name. If you need its display name, turn to Player.getDisplayName()

      Specified by:
      getName in interface IPlayer
      Returns:
      这个玩家的名称。
      The name of this player.
    • getUniqueId

      public UUID getUniqueId()
      Specified by:
      getUniqueId in interface IPlayer
    • getServer

      public Server getServer()
      Description copied from interface: IPlayer
      返回玩家所在的服务器。
      Returns the server carrying this player.
      Specified by:
      getServer in interface IPlayer
      Returns:
      玩家所在的服务器。
      the server carrying this player.
    • isOp

      public boolean isOp()
      Description copied from interface: ServerOperator
      返回这个对象是不是服务器管理员。
      Returns if this object is an operator.
      Specified by:
      isOp in interface ServerOperator
      Returns:
      这个对象是不是服务器管理员。
      if this object is an operator.
    • setOp

      public void setOp(boolean value)
      Description copied from interface: ServerOperator
      把这个对象设置成服务器管理员。
      Sets this object to be an operator or not to be.
      Specified by:
      setOp in interface ServerOperator
      Parameters:
      value - true为授予管理员,false为取消管理员。
      true for giving this operator or false for cancelling.
    • isBanned

      public boolean isBanned()
      Description copied from interface: IPlayer
      返回这个玩家是否被封禁(ban)。
      Returns if this player is banned.
      Specified by:
      isBanned in interface IPlayer
      Returns:
      这个玩家的名称。
      The name of this player.
      See Also:
    • setBanned

      public void setBanned(boolean value)
      Description copied from interface: IPlayer
      设置这个玩家是否被封禁(ban)。
      Sets this player to be banned or to be pardoned.
      Specified by:
      setBanned in interface IPlayer
      Parameters:
      value - 如果为true,封禁这个玩家。如果为false,解封这个玩家。
      true for ban and false for pardon.
      See Also:
    • isWhitelisted

      public boolean isWhitelisted()
      Description copied from interface: IPlayer
      返回这个玩家是否已加入白名单。
      Returns if this player is pardoned by whitelist.
      Specified by:
      isWhitelisted in interface IPlayer
      Returns:
      这个玩家是否已加入白名单。
      If this player is pardoned by whitelist.
      See Also:
    • setWhitelisted

      public void setWhitelisted(boolean value)
      Description copied from interface: IPlayer
      把这个玩家加入白名单,或者取消这个玩家的白名单。
      Adds this player to the white list, or removes it from the whitelist.
      Specified by:
      setWhitelisted in interface IPlayer
      Parameters:
      value - 如果为true,把玩家加入白名单。如果为false,取消这个玩家的白名单。
      true for add and false for remove.
      See Also:
    • getPlayer

      public Player getPlayer()
      Description copied from interface: IPlayer
      得到这个接口的Player对象。
      Returns a Player object for this interface.
      Specified by:
      getPlayer in interface IPlayer
      Returns:
      这个接口的 Player对象。
      a Player object for this interface.
      See Also:
    • getFirstPlayed

      public Long getFirstPlayed()
      Description copied from interface: IPlayer
      得到这个玩家第一次游戏的时间。
      Returns the time this player first played in this server.
      Specified by:
      getFirstPlayed in interface IPlayer
      Returns:
      Unix时间(以秒为单位。
      Unix time in seconds.
    • getLastPlayed

      public Long getLastPlayed()
      Description copied from interface: IPlayer
      得到这个玩家上次加入游戏的时间。
      Returns the time this player last joined in this server.
      Specified by:
      getLastPlayed in interface IPlayer
      Returns:
      Unix时间(以秒为单位。
      Unix time in seconds.
    • hasPlayedBefore

      public boolean hasPlayedBefore()
      Description copied from interface: IPlayer
      返回这个玩家以前是否来过服务器。
      Returns if this player has played in this server before.

      如果想得到这个玩家是不是第一次玩,可以使用:
      If you want to know if this player is the first time playing in this server, you can use:

      if(!player.hasPlayerBefore()) {...}
      Specified by:
      hasPlayedBefore in interface IPlayer
      Returns:
      这个玩家以前是不是玩过游戏。
      If this player has played in this server before.
    • setMetadata

      public void setMetadata(String metadataKey, MetadataValue newMetadataValue)
      Specified by:
      setMetadata in interface Metadatable
    • getMetadata

      public List<MetadataValue> getMetadata(String metadataKey)
      Specified by:
      getMetadata in interface Metadatable
    • hasMetadata

      public boolean hasMetadata(String metadataKey)
      Specified by:
      hasMetadata in interface Metadatable
    • removeMetadata

      public void removeMetadata(String metadataKey, Plugin owningPlugin)
      Specified by:
      removeMetadata in interface Metadatable