mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 08:44:01 +00:00
Player: added locking variable to prevent reentry into respawn() while awaiting spawn terrain generation
This commit is contained in:
parent
34ee1c2354
commit
42e915b902
@ -229,6 +229,8 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
||||
/** @var Position|null */
|
||||
private $spawnPosition = null;
|
||||
|
||||
private bool $respawnLocked = false;
|
||||
|
||||
//TODO: Abilities
|
||||
/** @var bool */
|
||||
protected $autoJump = true;
|
||||
@ -2115,6 +2117,10 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
||||
}
|
||||
|
||||
public function respawn() : void{
|
||||
if($this->respawnLocked){
|
||||
return;
|
||||
}
|
||||
$this->respawnLocked = true;
|
||||
if($this->server->isHardcore()){
|
||||
if($this->kick("You have been banned because you died in hardcore mode")){ //this allows plugins to prevent the ban by cancelling PlayerKickEvent
|
||||
$this->server->getNameBans()->addBan($this->getName(), "Died in hardcore mode");
|
||||
@ -2156,6 +2162,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
||||
$this->scheduleUpdate();
|
||||
|
||||
$this->getNetworkSession()->onServerRespawn();
|
||||
$this->respawnLocked = false;
|
||||
},
|
||||
function() : void{
|
||||
if($this->isConnected()){
|
||||
|
Loading…
x
Reference in New Issue
Block a user