players are now invisible in spectator, methods for making player invisible added

This commit is contained in:
GameHerobrine 2022-09-24 23:25:34 +03:00
parent 819803c634
commit c03653a050
2 changed files with 21 additions and 2 deletions

View file

@ -890,7 +890,16 @@ class Player{
}
}
}
public function makeInvisibleForOnePlayer(Player $player){
$pk = new RemoveEntityPacket;
$pk->eid = $this->entity->eid;
$player->dataPacket($pk);
}
public function makeInvisibleForAllPlayers(){
$pk = new RemoveEntityPacket;
$pk->eid = $this->entity->eid;
$this->server->api->player->broadcastPacket($this->server->api->player->getAll($this->level), $pk);
}
public function getGamemode(){
switch($this->gamemode){
case SURVIVAL:
@ -941,6 +950,14 @@ class Player{
$this->sendChat("Your gamemode has been changed to " . $this->getGamemode() . ", you've to do a forced reconnect.\n");
$this->server->schedule(30, [$this, "close"], "gamemode change"); //Forces a kick
}
if($this->gamemode === SPECTATOR){
$this->makeInvisibleForAllPlayers();
}
if($this->gamemode === CREATIVE){
$this->server->api->player->spawnToAllPlayers($this);
}
$this->inventory = $inv;
$this->sendSettings();
$this->sendInventory();