本文整理汇总了PHP中pocketmine\Player::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP Player::getName方法的具体用法?PHP Player::getName怎么用?PHP Player::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\Player
的用法示例。
在下文中一共展示了Player::getName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: removeSpectator
public function removeSpectator(Player $player)
{
if (isset($this->spectators[strtolower($player->getName())])) {
unset($this->spectators[strtolower($player->getName())]);
}
$this->update();
}
示例2: setExempt
/**
* @param Player $player
* @param bool $value
*/
public function setExempt(Player $player, $value = true)
{
if ($value) {
$this->exempts->set(strtolower($player->getName()));
$this->exempts->save();
} else {
$this->exempts->remove(strtolower($player->getName()));
$this->exempts->save();
}
}
示例3: handle
private function handle($cmd, $args, Player $player, CommandSender $issuer)
{
switch ($cmd) {
case "getping":
$issuer->sendMessage("Ping of " . $player->getName() . ": unknown ms");
return true;
case "seearmor":
$issuer->sendMessage("Armor of " . $player->getName() . ":");
$issuer->sendMessage("Helmet: " . $this->formatItem($player->getInventory()->getArmorItem(0)));
$issuer->sendMessage("Chestplate: " . $this->formatItem($player->getInventory()->getArmorItem(1)));
$issuer->sendMessage("Leggings: " . $this->formatItem($player->getInventory()->getArmorItem(2)));
$issuer->sendMessage("Boots: " . $this->formatItem($player->getInventory()->getArmorItem(3)));
return true;
case "seegm":
$issuer->sendMessage("Gamemode of " . $player->getName() . ": " . $this->formatGamemode($player->getGamemode()));
return true;
case "getpos":
$issuer->sendMessage($player->getName() . " is at (" . TextFormat::YELLOW . $player->x . ", " . TextFormat::GREEN . $player->y . ", " . TextFormat::AQUA . $player->z . ") in world " . TextFormat::RED . $player->getLevel()->getName() . ".");
return true;
case "setarmor":
// TODO
break;
case "rmarmor":
// TODO
break;
case "sessions":
// TODO
break;
}
return false;
}
示例4: getAttachment
/**
* @param Player $player
* @return mixed
*/
public function getAttachment(Player $player)
{
if (!isset($this->attachments[$player->getName()])) {
$this->attachments[$player->getName()] = $player->addAttachment($this);
}
return $this->attachments[$player->getName()];
}
示例5: getPlayerConfig
/**
* @param Player $player
* @return Config
*/
public function getPlayerConfig(Player $player, $world)
{
if (!file_exists($this->getDataFolder() . $world . "/players/" . strtolower($player->getName()) . ".yml")) {
return new Config($this->getDataFolder() . $world . "/players/" . strtolower($player->getName()) . ".yml", Config::YAML, ["userName" => $player->getName(), "armor" => [], "items" => []]);
}
return new Config($this->getDataFolder() . $world . "/players/" . strtolower($player->getName()) . ".yml", Config::YAML, []);
}
示例6: reduceMoney
public function reduceMoney(Player $player, $amount)
{
$money = $this->plugin->getMoney($player->getName());
if ($money === false or $money - $amount < 0) {
return false;
}
return $this->plugin->setMoney($player->getName(), $money - $amount);
}
示例7: restorePlayer
public function restorePlayer(Player $player)
{
if (isset($this->players[$player->getName()])) {
$get = $this->players[$player->getName()];
$player->setGamemode($get["gamemode"]);
$player->getInventory()->setContents(unserialize($get["inventory"]));
$player->getInventory()->setArmorContents(unserialize($get["armor"]));
$player->teleport(unserialize($get["spawn"]));
unset($this->players[$player->getName()]);
}
}
示例8: onRun
public function onRun(array $args, Faction $faction, Player $player)
{
$reason = implode(" ", $args);
$members = $faction->getMembers(true);
unset($members[strtolower($player->getName())]);
$faction->setMembers($members);
$faction->sendMessage($player->getName() . " quitted the faction.", Faction::CHAT_ANNOUNCEMENT);
if (strlen($reason) > 0) {
$faction->sendMessage("Reason: {$reason}");
}
return "[PF] You have successfully quitted {$faction}.";
}
示例9: checkMove
public function checkMove(Player &$player, $time)
{
if ($time - $this->past[$player->getName()] > 400) {
// stable->450 safe->600
$x = -\sin($player->yaw / 180 * M_PI) * \cos($player->pitch / 180 * M_PI);
$y = -\sin($player->pitch / 180 * M_PI);
$z = \cos($player->yaw / 180 * M_PI) * \cos($player->pitch / 180 * M_PI);
$player->addEntityMotion(0, $x, $y, $z);
// echo "c! " . ($time - $this->past [$player->getName ()]) . "\n";
// echo "n! " . $x . ":" . $y . ":" . $z . "\n";
}
$this->past[$player->getName()] = $time;
}
示例10: getBal
public function getBal(Player $player)
{
if (!$this->checkReady()) {
return false;
}
//TODO there is probably a better way to do this
$money = $this->getAPI()->getAllMoney();
if (isset($money["money"][strtolower($player->getName())])) {
return $money["money"][strtolower($player->getName())];
} else {
return false;
}
}
示例11: onRun
public function onRun(array $args, Player $player)
{
$cd = false;
$mode = 0;
// 0 for set hand, 1 for view, 2 for removal
while (isset($args[0])) {
$arg = array_shift($args);
switch ($arg) {
case "cd":
case "check-damage":
$cd = true;
break;
case "v":
case "view":
$mode = 1;
break;
case "del":
case "delete":
case "rm":
case "remove":
$mode = 2;
break;
}
}
switch ($mode) {
case 0:
$item = $player->getInventory()->getItemInHand();
if ($item instanceof Air) {
return "You cannot use air (hand) as your tool! Use '//{$this->getName()} rm' to delete the tool.";
}
$provider = $this->getMain()->getPlayerDataProvider();
/** @var PlayerData $data */
$data = $provider[strtolower($player->getName())];
$id = $item->getID();
$damage = $cd ? $item->getDamage() : PlayerData::ALLOW_ANY;
$data->setTool($this->id, new SelectedTool($id, $damage, $this->getDefaultID(), $this->getDefaultDamage()));
return "Your {$this->name} item is now {$id}" . (is_int($damage) ? ":{$damage}" : " (no damage value specified") . ".";
case 1:
/** @var PlayerData $data */
$data = $this->getMain()->getPlayerDataProvider()[strtolower($player->getName())];
$tool = $data->getTool($this->id);
$id = $tool->getRawID();
$damage = $tool->getRawDamage();
return "Your {$this->name} item is {$id}" . (is_int($damage) ? ":{$damage}" : " (no damage value specified") . ".";
default:
/** @var PlayerData $data */
$data = $this->getMain()->getPlayerDataProvider()[strtolower($player->getName())];
$data->setTool($this->id, new SelectedTool(0, PlayerData::ALLOW_ANY, $this->getDefaultID(), $this->getDefaultDamage()));
return "Your {$this->name} item has been removed.";
}
}
示例12: getPlayerRank
/**
* @param Player $player
* @return string
*/
public function getPlayerRank(Player $player)
{
if ($this->getAPI()->isInFaction($player->getName())) {
if ($this->getAPI()->isOfficer($player->getName())) {
return '*';
} elseif ($this->getAPI()->isLeader($player->getName())) {
return '**';
} else {
return '';
}
}
// TODO
return '';
}
示例13: executeRankUp
public function executeRankUp(Player $player, $response, $gotreward = false)
{
$message = null;
switch ($response) {
case "0":
$message = str_replace("##voteurl##", $this->config->getVoteUrl(), $this->config->getMessage("vote-open"));
break;
case "1":
if ($gotreward == false) {
$this->requestApiTaks($player->getName(), "action=post&", true);
$this->rankUp->rankUp($this, $player);
$command = "say " . $this->config->getMessage("vote-success");
$this->getServer()->dispatchCommand(new ConsoleCommandSender(), str_replace("##player##", $player->getName(), $command));
}
break;
case "2":
$message = $this->config->getMessage("vote-nextday");
break;
default:
$message = $this->config->getMessage("error-fetching-vote");
$this->getLogger()->warning(TextFormat::RED . $message);
break;
}
if ($message) {
$this->getLogger()->info(TextFormat::GREEN . $message);
$player->sendMessage($message);
}
}
示例14: private_onLogin
private function private_onLogin(Player $player)
{
/** @var string|LoginDataQuery $LoginQuery */
$LoginQuery = $this->main->getLoginQueryImpl();
/** @noinspection PhpDeprecationInspection */
new $LoginQuery($this->main, $player->getId(), $player->getName(), $player->getAddress(), $player->getClientId());
}
示例15: openCrate
public function openCrate(Player $p)
{
if ($this->getConfig()->get("broadcast-message-on-open")) {
$this->getServer()->broadcastMessage(TextFormat::BOLD . TextFormat::GREEN . "[MysteryCrates] " . TextFormat::RESET . TextFormat::RED . $p->getName() . " opened a crate!");
//TODO
}
}