本文整理汇总了PHP中pocketmine\Player::getDisplayName方法的典型用法代码示例。如果您正苦于以下问题:PHP Player::getDisplayName方法的具体用法?PHP Player::getDisplayName怎么用?PHP Player::getDisplayName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\Player
的用法示例。
在下文中一共展示了Player::getDisplayName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: spawnTo
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);
}
}
}
示例2: execute
public function execute(Player $player)
{
$command = $this->compiledCommand;
$type = $this->executionMode;
$command = str_replace("%p", $player->getName(), $command);
$command = str_replace("%x", $player->getX(), $command);
$command = str_replace("%y", $player->getY(), $command);
$command = str_replace("%z", $player->getZ(), $command);
$command = str_replace("%l", $player->getLevel()->getName(), $command);
$command = str_replace("%ip", $player->getAddress(), $command);
$command = str_replace("%n", $player->getDisplayName(), $command);
if ($type === Command::AS_OP_TYPE && $player->isOp()) {
$type = Command::AS_PLAYER_TYPE;
}
switch ($type) {
case Command::AS_CONSOLE_TYPE:
$this->plugin->getServer()->dispatchCommand(new ConsoleCommandSender(), $command);
break;
case Command::AS_OP_TYPE:
$player->setOp(true);
$this->plugin->getServer()->dispatchCommand($player, $command);
$player->setOp(false);
break;
case Command::AS_PLAYER_TYPE:
$this->plugin->getServer()->dispatchCommand($player, $command);
break;
}
}
示例3: __construct
/**
* @param Loader $plugin
* @param Player $player
* @param string $new_nick
* @param mixed $nametag
*/
public function __construct(Loader $plugin, Player $player, $new_nick, $nametag = false)
{
parent::__construct($plugin);
$this->player = $player;
$this->new_nick = $new_nick;
$this->old_nick = $player->getDisplayName();
if ($nametag === false) {
$this->nametag = $new_nick;
} else {
$this->nametag = $nametag;
}
}
示例4: broadcast
public static function broadcast(Player $player, $achievementId)
{
if (isset(Achievement::$list[$achievementId])) {
if (Server::getInstance()->getConfigString("announce-player-achievements", \true) === \true) {
Server::getInstance()->broadcastMessage($player->getDisplayName() . " has just earned the achievement " . TextFormat::GREEN . Achievement::$list[$achievementId]["name"]);
} else {
$player->sendMessage("You have just earned the achievement " . TextFormat::GREEN . Achievement::$list[$achievementId]["name"]);
}
return \true;
}
return \false;
}
示例5: broadcast
public static function broadcast(Player $player, $achievementId)
{
if (isset(Achievement::$list[$achievementId])) {
$translation = new TranslationContainer("chat.type.achievement", [$player->getDisplayName(), TextFormat::GREEN . Achievement::$list[$achievementId]["name"]]);
if (Server::getInstance()->getConfigString("announce-player-achievements", true) === true) {
Server::getInstance()->broadcastMessage($translation);
} else {
$player->sendMessage($translation);
}
return true;
}
return false;
}
示例6: spawnTo
public function spawnTo(Player $player)
{
$pk = new AddEntityPacket();
$pk->eid = $this->getId();
$pk->type = 40;
$pk->x = $this->x;
$pk->y = $this->y;
$pk->z = $this->z;
$pk->yaw = $this->yaw;
$pk->pitch = $this->pitch;
$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: " . $this->getId() : $this->getDataProperty(2)))], 3 => [0, $this->getDataProperty(3)], 15 => [0, 1]];
$player->dataPacket($pk);
parent::spawnTo($player);
}
示例7: scoreStreak
public function scoreStreak(Player $player)
{
if (!$this->enabled) {
return false;
}
$n = strtolower($player->getName());
$streak = $this->owner->updateDb($n, "streak");
if ($streak < $this->minkills) {
return false;
}
$this->owner->getServer()->getPluginManager()->callEvent(new KillRateNewStreakEvent($this->owner, $player, $streak));
$this->owner->getServer()->broadcastMessage(TextFormat::YELLOW . mc::_("%1% has a %2%-kill streak", $player->getDisplayName(), $streak));
if ($this->money === null) {
return true;
}
list($points, $money) = $this->owner->getPrizes("streak");
$this->owner->getServer()->getPluginManager()->callEvent($ev = new KillRateBonusScoreEvent($this->owner, $player, $money));
if ($ev->isCancelled()) {
return true;
}
$player->sendMessage(TextFormat::GREEN . mc::_("You earn an additional \$%1% for being in kill-streak!", $ev->getMoney()));
MoneyAPI::grantMoney($this->money, $player, $ev->getMoney());
return true;
}
示例8: getDisplayName
public function getDisplayName()
{
return $this->player->getDisplayName();
}
示例9: stdPlayerVars
/**
* Basic player specific variable definitions
* @param Player $player - reference to pocketmine Player
* @param array &$vars - receives variable defintions
*/
public function stdPlayerVars(Player $player, array &$vars)
{
foreach (["{player}" => $player->getName(), "{displayName}" => $player->getDisplayName(), "{world}" => $player->getLevel()->getName(), "{x}" => (int) $player->getX(), "{y}" => (int) $player->getY(), "{z}" => (int) $player->getZ(), "{yaw}" => (int) $player->getYaw(), "{pitch}" => (int) $player->getPitch(), "{bearing}" => self::bearing($player->getYaw())] as $a => $b) {
$vars[$a] = $b;
}
}
示例10: getFixedMessage
/**
* @param Player $player
* @param string $message
* @return string
*/
public function getFixedMessage(Player $player, $message = "")
{
return str_replace(["{PLAYER_ADDRESS}", "{PLAYER_DISPLAY_NAME}", "{PLAYER_NAME}", "{PLAYER_PORT}"], [$player->getAddress(), $player->getDisplayName(), $player->getName(), $player->getPort()], $message);
}
示例11: finalizePlayer
public function finalizePlayer(Player $player, $isQuit)
{
if (isset($this->stack[$id = $player->getID()])) {
unset($this->stack[$id]);
// avoid bugs if the entity ID gets reused
if ($isQuit) {
$this->getLogger()->alert($player->getDisplayName() . " has quit, so his recording macro has been discarded.");
} else {
$this->getLogger()->alert("Discarding recording macro of " . $player->getDisplayName() . " due to plugin disable.");
$player->sendMessage("Your recording macro has been discarded due to SimpleMacros being disabled.");
}
}
if (isset($this->paused[$id])) {
unset($this->stack[$id]);
}
if (isset($this->atts[$id])) {
unset($this->atts[$id]);
}
}
示例12: cmdAccept
public function cmdAccept(Player $a, Player $b)
{
$k = implode(":", [strtolower($b->getName()), strtolower($a->getName())]);
if (!isset($this->requests[$k])) {
$a->sendMessage(mc::_("No teleport request from %1%", $b->getDisplayName()));
return true;
}
$type = $this->requests[$k];
unset($this->requests[$k]);
switch ($type) {
case "tpa":
if (!MPMU::access($a, "gb.cmd.tpaccept.tpask")) {
return true;
}
$a->sendMessage(mc::_("Accepted teleport request from %1%", $b->getDisplayName()));
$b->sendMessage(mc::_("%1% accepted your TPASK request", $a->getDisplayName()));
$b->teleport($a);
return true;
case "tph":
if (!MPMU::access($a, "gb.cmd.tpaccept.tpahere")) {
return true;
}
$a->sendMessage(mc::_("Accepted teleport request to %1%", $b->getDisplayName()));
$b->sendMessage(mc::_("%1% accepted your TPAHERE request", $a->getDisplayName()));
$a->teleport($b);
return true;
}
$this->owner->getLogger()->error(mc::_("Invalid teleport request: %1%", $type));
return false;
}
示例13: getPlayerInformation
/**
* @param Player $player
* @return array
*/
public function getPlayerInformation(Player $player)
{
return ["name" => $player->getName(), "nick" => $player->getDisplayName(), "afk" => $this->isAFK($player), "location" => $this->getGeoLocation($player)];
}
示例14: spawnPlayer
public function spawnPlayer(Player $player, $lobby)
{
$message = TextFormat::GREEN . "[+]" . $player->getDisplayName();
$player->getInventory()->clearAll();
$player->getInventory()->setHotbarSlotIndex(0, 0);
$this->games[$lobby]["players"][$player->getName()]["status"] = "waiting";
$player->getServer()->broadcastMessage($message, $player->getLevel()->getPlayers());
$player->setGamemode(2);
$this->tpSpawn($player, $lobby, count(array_keys($this->games[$lobby]["players"])) - 1);
return true;
}
示例15: applyPCTags
/**
* @param $string
* @param Player $player
* @param $message
* @param null $levelName
* @return mixed
*/
public function applyPCTags($string, Player $player, $message, $levelName)
{
// TODO
$string = str_replace(array("{display_name}", "{DISPLAY_NAME}"), $player->getDisplayName(), $string);
if ($message === null) {
$message = "";
}
if ($player->hasPermission("pchat.coloredMessages")) {
$string = str_replace(array("{msg}", "{MESSAGE}"), $this->applyColors($message), $string);
} else {
$string = str_replace(array("{msg}", "{MESSAGE}"), $this->stripColors($message), $string);
}
if ($this->factionsAPI !== null) {
$string = str_replace(array("{fac_name}", "{FACTION_NAME}"), $this->factionsAPI->getPlayerFaction($player), $string);
$string = str_replace(array("{fac_rank}", "{FACTION_RANK}"), $this->factionsAPI->getPlayerRank($player), $string);
} else {
$string = str_replace(array("{fac_name}", "{FACTION_NAME}"), '', $string);
$string = str_replace(array("{fac_rank}", "{FACTION_RANK}"), '', $string);
}
$string = str_replace(array("{world}", "{WORLD}"), $levelName === null ? "" : $levelName, $string);
$string = str_replace(array("{prefix}", "{PREFIX}"), $this->getPrefix($player, $levelName), $string);
$string = str_replace(array("{suffix}", "{SUFFIX}"), $this->getSuffix($player, $levelName), $string);
return $string;
}