pocketmine\Player::getDisplayName PHP Method

getDisplayName() public method

Gets the "friendly" name to display of this player to use in the chat.
public getDisplayName ( ) : string
return string
    public function getDisplayName()
    {
        return $this->displayName;
    }

Usage Example

Example #1
0
 public function spawnTo(Player $player)
 {
     if ($player !== $this and !isset($this->hasSpawned[$player->getLoaderId()])) {
         $this->hasSpawned[$player->getLoaderId()] = $player;
         $uuid = $this->getUniqueId();
         $entityId = $this->getId();
         $pk = new AddPlayerPacket();
         $pk->uuid = $uuid;
         $pk->username = "";
         $pk->eid = $entityId;
         $pk->x = $this->x;
         $pk->y = $this->y;
         $pk->z = $this->z;
         $pk->yaw = $this->yaw;
         $pk->pitch = $this->pitch;
         $pk->item = $this->getInventory()->getItemInHand();
         $pk->metadata = [2 => [4, str_ireplace("{name}", $player->getName(), str_ireplace("{display_name}", $player->getDisplayName(), $player->hasPermission("slapper.seeId") ? $this->getDataProperty(2) . "\n" . \pocketmine\utils\TextFormat::GREEN . "Entity ID: " . $entityId : $this->getDataProperty(2)))], 3 => [0, $this->getDataProperty(3)], 15 => [0, 1]];
         $player->dataPacket($pk);
         $this->inventory->sendArmorContents($player);
         $add = new PlayerListPacket();
         $add->type = 0;
         $add->entries[] = [$uuid, $entityId, isset($this->namedtag->MenuName) ? $this->namedtag["MenuName"] : "", $this->skinName, $this->skin];
         $player->dataPacket($add);
         if ($this->namedtag["MenuName"] === "") {
             $remove = new PlayerListPacket();
             $remove->type = 1;
             $remove->entries[] = [$uuid];
             $player->dataPacket($remove);
         }
     }
 }
All Usage Examples Of pocketmine\Player::getDisplayName
Player