当前位置: 首页>>代码示例>>PHP>>正文


PHP Human::close方法代码示例

本文整理汇总了PHP中pocketmine\entity\Human::close方法的典型用法代码示例。如果您正苦于以下问题:PHP Human::close方法的具体用法?PHP Human::close怎么用?PHP Human::close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pocketmine\entity\Human的用法示例。


在下文中一共展示了Human::close方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: close

 /**
  * @param string $message Message to be broadcasted
  * @param string $reason  Reason showed in console
  */
 public function close($message = "", $reason = "generic reason")
 {
     foreach ($this->tasks as $task) {
         $task->cancel();
     }
     $this->tasks = [];
     if ($this->connected and !$this->closed) {
         if ($reason != "") {
             $pk = new DisconnectPacket();
             $pk->message = $reason;
             $this->directDataPacket($pk);
         }
         $this->connected = false;
         if ($this->username != "") {
             $this->server->getPluginManager()->callEvent($ev = new PlayerQuitEvent($this, $message));
             if ($this->server->getAutoSave() and $this->loggedIn === true) {
                 $this->save();
             }
         }
         foreach ($this->server->getOnlinePlayers() as $player) {
             if (!$player->canSee($this)) {
                 $player->showPlayer($this);
             }
         }
         $this->hiddenPlayers = [];
         foreach ($this->windowIndex as $window) {
             $this->removeWindow($window);
         }
         $this->interface->close($this, $reason);
         $chunkX = $chunkZ = null;
         foreach ($this->usedChunks as $index => $d) {
             if (PHP_INT_SIZE === 8) {
                 $chunkX = $index >> 32 << 32 >> 32;
                 $chunkZ = ($index & 0xffffffff) << 32 >> 32;
             } else {
                 list($chunkX, $chunkZ) = explode(":", $index);
                 $chunkX = (int) $chunkX;
                 $chunkZ = (int) $chunkZ;
             }
             $this->level->freeChunk($chunkX, $chunkZ, $this);
             unset($this->usedChunks[$index]);
         }
         parent::close();
         if ($this->loggedIn) {
             $this->server->removeOnlinePlayer($this);
         }
         $this->loggedIn = false;
         if (isset($ev) and $this->username != "" and $this->spawned !== false and $ev->getQuitMessage() != "") {
             $this->server->broadcastMessage($ev->getQuitMessage());
         }
         $this->server->getPluginManager()->unsubscribeFromPermission(Server::BROADCAST_CHANNEL_USERS, $this);
         $this->spawned = false;
         $this->server->getLogger()->info(TextFormat::AQUA . $this->username . TextFormat::WHITE . "/" . $this->ip . " logged out due to " . str_replace(["\n", "\r"], [" ", ""], $reason));
         $this->windows = new \SplObjectStorage();
         $this->windowIndex = [];
         $this->usedChunks = [];
         $this->loadQueue = [];
         $this->hasSpawned = [];
         $this->spawnPosition = null;
         unset($this->buffer);
     }
     $this->perm->clearPermissions();
     $this->server->removePlayer($this);
 }
开发者ID:ZenaGamingsky,项目名称:Steadfast2,代码行数:68,代码来源:Player.php

示例2: close

 /**
  * Note for plugin developers: use kick() with the isAdmin
  * flag set to kick without the "Kicked by admin" part instead of this method.
  *
  * @param string $message Message to be broadcasted
  * @param string $reason  Reason showed in console
  * @param bool $notify
  */
 public final function close($message = "", $reason = "generic reason", $notify = true)
 {
     if ($this->connected and !$this->closed) {
         if ($notify and strlen((string) $reason) > 0) {
             $pk = new DisconnectPacket();
             $pk->message = $reason;
             $this->directDataPacket($pk);
         }
         $this->connected = false;
         if (strlen($this->getName()) > 0) {
             $this->server->getPluginManager()->callEvent($ev = new PlayerQuitEvent($this, $message, true));
             if ($this->loggedIn === true and $ev->getAutoSave()) {
                 $this->save();
             }
         }
         foreach ($this->server->getOnlinePlayers() as $player) {
             if (!$player->canSee($this)) {
                 $player->showPlayer($this);
             }
         }
         $this->hiddenPlayers = [];
         foreach ($this->windowIndex as $window) {
             $this->removeWindow($window);
         }
         foreach ($this->usedChunks as $index => $d) {
             Level::getXZ($index, $chunkX, $chunkZ);
             $this->level->unregisterChunkLoader($this, $chunkX, $chunkZ);
             unset($this->usedChunks[$index]);
         }
         parent::close();
         $this->interface->close($this, $notify ? $reason : "");
         if ($this->loggedIn) {
             $this->server->removeOnlinePlayer($this);
         }
         $this->loggedIn = false;
         if (isset($ev) and $this->username != "" and $this->spawned !== false and $ev->getQuitMessage() != "") {
             $this->server->broadcastMessage($ev->getQuitMessage());
         }
         $this->server->getPluginManager()->unsubscribeFromPermission(Server::BROADCAST_CHANNEL_USERS, $this);
         $this->spawned = false;
         $this->server->getLogger()->info($this->getServer()->getLanguage()->translateString("pocketmine.player.logOut", [TextFormat::AQUA . $this->getName() . TextFormat::WHITE, $this->ip, $this->port, $this->getServer()->getLanguage()->translateString($reason)]));
         $this->windows = new \SplObjectStorage();
         $this->windowIndex = [];
         $this->usedChunks = [];
         $this->loadQueue = [];
         $this->hasSpawned = [];
         $this->spawnPosition = null;
         unset($this->buffer);
     }
     if ($this->perm !== null) {
         $this->perm->clearPermissions();
         $this->perm = null;
     }
     if ($this->inventory !== null) {
         $this->inventory = null;
         $this->currentTransaction = null;
     }
     $this->chunk = null;
     $this->server->removePlayer($this);
 }
开发者ID:NewDelion,项目名称:PocketMine-0.13.x,代码行数:68,代码来源:Player.php

示例3: close

 /**
  * @param string $message Message to be broadcasted
  * @param string $reason  Reason showed in console
  */
 public function close($message = "", $reason = "generic reason")
 {
     foreach ($this->tasks as $task) {
         $task->cancel();
     }
     $this->tasks = [];
     if ($this->connected and !$this->closed) {
         $this->connected = false;
         if ($this->username != "") {
             $this->server->getPluginManager()->callEvent($ev = new PlayerQuitEvent($this, $message));
             if ($this->server->getAutoSave() and $this->loggedIn === true) {
                 $this->save();
             }
         }
         foreach ($this->windowIndex as $window) {
             $this->removeWindow($window);
         }
         $this->interface->close($this, $reason);
         $chunkX = $chunkZ = null;
         foreach ($this->usedChunks as $index => $d) {
             Level::getXZ($index, $chunkX, $chunkZ);
             $this->level->freeChunk($chunkX, $chunkZ, $this);
             unset($this->usedChunks[$index]);
         }
         parent::close();
         $this->loggedIn = false;
         if (isset($ev) and $this->username != "" and $this->spawned !== false and $ev->getQuitMessage() != "") {
             $this->server->broadcastMessage($ev->getQuitMessage());
         }
         $this->server->getPluginManager()->unsubscribeFromPermission(Server::BROADCAST_CHANNEL_USERS, $this);
         $this->spawned = false;
         $this->server->getLogger()->info(TextFormat::AQUA . $this->username . TextFormat::WHITE . "[/" . $this->ip . ":" . $this->port . "] logged out due to " . str_replace(["\n", "\r"], [" ", ""], $reason));
         $this->windows = new \SplObjectStorage();
         $this->windowIndex = [];
         $this->usedChunks = [];
         $this->loadQueue = [];
         $this->hasSpawned = [];
         $this->spawnPosition = null;
         unset($this->buffer);
     }
     $this->perm->clearPermissions();
     $this->server->removePlayer($this);
 }
开发者ID:rryy,项目名称:PocketMine-MP,代码行数:47,代码来源:Player.php

示例4: close

 /**
  * Note for plugin developers: use kick() with the isAdmin
  * flag set to kick without the "Kicked by admin" part instead of this method.
  *
  * @param string $message Message to be broadcasted
  * @param string $reason Reason showed in console
  * @param bool   $notify
  */
 public final function close($message = "", $reason = "generic reason", $notify = true)
 {
     if ($this->connected and !$this->closed) {
         if ($notify and strlen((string) $reason) > 0) {
             $pk = new DisconnectPacket();
             $pk->message = $reason;
             $this->directDataPacket($pk);
         }
         //$this->setLinked();
         if ($this->fishingHook instanceof FishingHook) {
             $this->fishingHook->close();
             $this->fishingHook = null;
         }
         $this->removeEffect(Effect::HEALTH_BOOST);
         $this->connected = false;
         if (strlen($this->getName()) > 0) {
             $this->server->getPluginManager()->callEvent($ev = new PlayerQuitEvent($this, $message, true));
             if ($this->loggedIn === true and $ev->getAutoSave()) {
                 $this->save();
             }
         }
         foreach ($this->server->getOnlinePlayers() as $player) {
             if (!$player->canSee($this)) {
                 $player->showPlayer($this);
             }
         }
         $this->hiddenPlayers = [];
         foreach ($this->windowIndex as $window) {
             $this->removeWindow($window);
         }
         foreach ($this->usedChunks as $index => $d) {
             Level::getXZ($index, $chunkX, $chunkZ);
             $this->level->unregisterChunkLoader($this, $chunkX, $chunkZ);
             unset($this->usedChunks[$index]);
         }
         parent::close();
         $this->interface->close($this, $notify ? $reason : "");
         if ($this->loggedIn) {
             $this->server->removeOnlinePlayer($this);
         }
         $this->loggedIn = false;
         if (isset($ev) and $this->username != "" and $this->spawned !== false and $ev->getQuitMessage() != "") {
             if ($this->server->playerMsgType === Server::PLAYER_MSG_TYPE_MESSAGE) {
                 $this->server->broadcastMessage($ev->getQuitMessage());
             } elseif ($this->server->playerMsgType === Server::PLAYER_MSG_TYPE_TIP) {
                 $this->server->broadcastTip(str_replace("@player", $this->getName(), $this->server->playerLogoutMsg));
             } elseif ($this->server->playerMsgType === Server::PLAYER_MSG_TYPE_POPUP) {
                 $this->server->broadcastPopup(str_replace("@player", $this->getName(), $this->server->playerLogoutMsg));
             }
         }
         $this->server->getPluginManager()->unsubscribeFromPermission(Server::BROADCAST_CHANNEL_USERS, $this);
         $this->spawned = false;
         $this->server->getLogger()->info($this->getServer()->getLanguage()->translateString("pocketmine.player.logOut", [TextFormat::AQUA . $this->getName() . TextFormat::WHITE, $this->ip, $this->port, $this->getServer()->getLanguage()->translateString($reason)]));
         $this->windows = new \SplObjectStorage();
         $this->windowIndex = [];
         $this->usedChunks = [];
         $this->loadQueue = [];
         $this->hasSpawned = [];
         $this->spawnPosition = null;
         unset($this->buffer);
         if ($this->server->dserverConfig["enable"] and $this->server->dserverConfig["queryAutoUpdate"]) {
             $this->server->updateQuery();
         }
     }
     if ($this->perm !== null) {
         $this->perm->clearPermissions();
         $this->perm = null;
     }
     $this->inventory = null;
     $this->transactionQueue = null;
     $this->chunk = null;
     $this->server->removePlayer($this);
 }
开发者ID:iTXTech,项目名称:Genisys,代码行数:81,代码来源:Player.php

示例5: onUpdate

 public function onUpdate($currentTick)
 {
     $p = $this->player;
     if ($this->closed == true || $this->dead == true || !$p instanceof Player || !$p->isSleeping()) {
         if (!$this->closed) {
             parent::close();
         }
         $this->player = false;
         return false;
     } else {
         if ($this->healTick >= 60) {
             $p->heal(1);
             $this->healTick = 0;
         }
         $this->healTick++;
         $name = "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
         $name .= "Healing...";
         if ($this->healTick < 55) {
             $name .= "\n    " . (3 - floor($this->healTick * 0.05)) . "...";
             $name .= ["-", "\\", ".|", "/"][floor($this->healTick * 0.5) % 4];
         }
         $property = (new \ReflectionClass("\\pocketmine\\Player"))->getProperty("sleeping");
         $property->setAccessible(true);
         $b = $this->getLevel()->getBlock($property->getValue($p));
         $xTabel = [1 => 2, 3 => -2, 9 => 2, 11 => -2];
         $x = isset($xTabel[$dmg = $b->getDamage()]) ? $xTabel[$dmg] : 0.5;
         $zTabel = [0 => -2, 2 => 2, 8 => -2, 10 => 2];
         $z = isset($zTabel[$dmg]) ? $zTabel[$dmg] : 0.5;
         $this->x = $b->x + $x . ($this->y = $p->y + 19);
         $this->z = $b->z + $z;
         if ($this->nameTag !== $name) {
             $this->nameTag = $name;
             $this->despawnFrom($p);
         }
         $this->spawnTo($p);
         $pk = new MovePlayerPacket();
         $pk->eid = $this->id;
         $pk->x = $this->x;
         $pk->y = $this->y;
         $pk->z = $this->z;
         $pk->yaw = 0;
         $pk->bodyYaw = 0;
         $pk->pitch = 0;
         $p->getServer()->broadcastPacket($this->hasSpawned, $pk);
     }
     return true;
 }
开发者ID:Skull3x,项目名称:MineBlock,代码行数:47,代码来源:HealBed.php

示例6: close

 /**
  * @param string $message Message to be broadcasted
  * @param string $reason  Reason showed in console
  */
 public function close($message = "", $reason = "generic reason")
 {
     foreach ($this->tasks as $task) {
         $task->cancel();
     }
     $this->tasks = [];
     if ($this->connected === true) {
         if ($this->username != "") {
             $this->server->getPluginManager()->callEvent($ev = new PlayerQuitEvent($this, $message));
             if ($this->loggedIn === true) {
                 $this->save();
             }
         }
         $this->connected = false;
         $this->interface->close($this, $reason);
         $this->getLevel()->freeAllChunks($this);
         parent::close();
         $this->loggedIn = false;
         if (isset($ev) and $this->username != "" and $this->spawned !== false and $ev->getQuitMessage() != "") {
             $this->server->broadcastMessage($ev->getQuitMessage());
         }
         $this->server->getPluginManager()->unsubscribeFromPermission(Server::BROADCAST_CHANNEL_USERS, $this);
         $this->spawned = false;
         $this->server->getLogger()->info(TextFormat::AQUA . $this->username . TextFormat::WHITE . "[/" . $this->ip . ":" . $this->port . "] logged out due to " . str_replace(["\n", "\r"], [" ", ""], $reason));
         $this->windows = new \SplObjectStorage();
         $this->windowIndex = [];
         $this->usedChunks = [];
         $this->loadQueue = [];
         unset($this->buffer);
     }
     $this->server->removePlayer($this);
 }
开发者ID:boybook,项目名称:PocketMine-MP,代码行数:36,代码来源:Player.php

示例7: onUpdate

 public function onUpdate($currentTick)
 {
     $p = $this->player;
     if ($this->closed == true || $this->dead == true || $p instanceof Player && !$p->spawned) {
         if (!$this->closed) {
             parent::close();
         }
         $this->player = false;
         return false;
     } else {
         if ((($pitch = $p->getPitch()) >= 2 || $pitch <= -12) && !$p->isSleeping()) {
             $this->despawnFrom($p);
             return true;
         } else {
             $name = "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
             if ($p->dead) {
                 $name .= "You Dead...";
             } else {
                 $name .= "Health: " . $p->getHealth() . "/" . $p->getMaxHealth() . " " . $p->getHealth() / $p->getMaxHealth() * 100 . "%";
             }
             if ($p->isSleeping()) {
                 $property = (new \ReflectionClass("\\pocketmine\\Player"))->getProperty("sleeping");
                 $property->setAccessible(true);
                 $b = $this->getLevel()->getBlock($property->getValue($p));
                 $xTabel = [1 => 2, 3 => -2, 9 => 2, 11 => -2];
                 $x = isset($xTabel[$dmg = $b->getDamage()]) ? $xTabel[$dmg] : 0.5;
                 $zTabel = [0 => -2, 2 => 2, 8 => -2, 10 => 2];
                 $z = isset($zTabel[$dmg]) ? $zTabel[$dmg] : 0.5;
                 $this->x = $b->x + $x;
                 $this->y = $p->y + 19;
                 $this->z = $b->z + $z;
             } else {
                 $this->x = $p->x - sin($p->getyaw() / 180 * M_PI) * cos($p->getPitch() / 180 * M_PI * 3);
                 $this->y = $p->y + 20;
                 $this->z = $p->z + cos($p->getyaw() / 180 * M_PI) * cos($p->getPitch() / 180 * M_PI * 3);
             }
             if ($this->nameTag !== $name) {
                 $this->nameTag = $name;
                 $this->despawnFrom($p);
             }
             $this->spawnTo($p);
             $pk = new MovePlayerPacket();
             $pk->eid = $this->id;
             $pk->x = $this->x;
             $pk->y = $this->y;
             $pk->z = $this->z;
             $pk->yaw = 0;
             $pk->bodyYaw = 0;
             $pk->pitch = 0;
             $p->getServer()->broadcastPacket($this->hasSpawned, $pk);
         }
     }
     return true;
 }
开发者ID:Skull3x,项目名称:MineBlock,代码行数:54,代码来源:MaxHealth.php


注:本文中的pocketmine\entity\Human::close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。