Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function closePlayer(Player $p, $left = false, $spectate = false)
- {
- if ($this->quit($p->getName(), $left, $spectate)) {
- $p->gamemode = 3;//Just to make sure setGamemode() won't return false if the gm is the same
- $p->setGamemode($p->getServer()->getDefaultGamemode());
- $p->getInventory()->clearAll();
- $p->removeAllEffects();
- if ($p->isAlive()) {
- $p->setSprinting(false);
- $p->setSneaking(false);
- $p->extinguish();
- $p->setMaxHealth(20);
- $p->setMaxHealth($p->getMaxHealth());
- if ($p->getAttributeMap() != null) {//just to be really sure
- $p->setHealth($p->getMaxHealth());
- $p->setFood(20);
- }
- }
- if (!$spectate) {
- } elseif ($this->GAME_STATE > 0 && 1 < count($this->players)) {
- $p->gamemode = Player::SPECTATOR;
- $p->setGamemode(3);
- $p->spawnToAll();
- $p->sendPopup("§8-§7 Вы теперь спектатор §8-");
- $p->addEffect(Effect::getEffect(15)->setAmplifier(1)->setDuration(20*3)->setVisible(true));
- foreach ($this->players as $dname => $spawn) {
- if (($d = $this->pg->getServer()->getPlayer($dname)) instanceof Player)
- $d->hidePlayer($p);
- }
- $idmeta = explode(':', $this->pg->configs['spectator.quit.item']);
- $p->getInventory()->setHeldItemIndex(1);
- $p->getInventory()->setItem(0, Item::get((int)$idmeta[0], (int)$idmeta[1], 1));
- $p->getInventory()->sendContents($p);
- $p->getInventory()->sendContents($p->getViewers());
- $p->getInventory()->setHotbarSlotIndex(0, 0);
- $p->sendMessage($this->pg->lang['death.spectator']);
- }
- return true;
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement