Advertisement
Guest User

Untitled

a guest
Dec 11th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. public function closePlayer(Player $p, $left = false, $spectate = false)
  2. {
  3. if ($this->quit($p->getName(), $left, $spectate)) {
  4. $p->gamemode = 3;//Just to make sure setGamemode() won't return false if the gm is the same
  5. $p->setGamemode($p->getServer()->getDefaultGamemode());
  6. $p->getInventory()->clearAll();
  7. $p->removeAllEffects();
  8. if ($p->isAlive()) {
  9. $p->setSprinting(false);
  10. $p->setSneaking(false);
  11. $p->extinguish();
  12. $p->setMaxHealth(20);
  13. $p->setMaxHealth($p->getMaxHealth());
  14. if ($p->getAttributeMap() != null) {//just to be really sure
  15. $p->setHealth($p->getMaxHealth());
  16. $p->setFood(20);
  17. }
  18. }
  19. if (!$spectate) {
  20.  
  21. } elseif ($this->GAME_STATE > 0 && 1 < count($this->players)) {
  22. $p->gamemode = Player::SPECTATOR;
  23. $p->setGamemode(3);
  24. $p->spawnToAll();
  25. $p->sendPopup("§8-§7 Вы теперь спектатор §8-");
  26. $p->addEffect(Effect::getEffect(15)->setAmplifier(1)->setDuration(20*3)->setVisible(true));
  27. foreach ($this->players as $dname => $spawn) {
  28. if (($d = $this->pg->getServer()->getPlayer($dname)) instanceof Player)
  29. $d->hidePlayer($p);
  30. }
  31. $idmeta = explode(':', $this->pg->configs['spectator.quit.item']);
  32. $p->getInventory()->setHeldItemIndex(1);
  33. $p->getInventory()->setItem(0, Item::get((int)$idmeta[0], (int)$idmeta[1], 1));
  34. $p->getInventory()->sendContents($p);
  35. $p->getInventory()->sendContents($p->getViewers());
  36. $p->getInventory()->setHotbarSlotIndex(0, 0);
  37. $p->sendMessage($this->pg->lang['death.spectator']);
  38. }
  39. return true;
  40. }
  41. return false;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement