Player: Improved hardcore death handling

it's now possible to cancel the banning by cancelling PlayerKickEvent.
In addition, the disconnect message will now properly explain why the player is banned instead of just saying 'You have been banned',
and also banned-players.txt will show 'Died in hardcore mode' as the reason instead of being completely blank (seriously, we couldn't tell the difference between real bans and hardcore bans????)
This commit is contained in:
Dylan K. Taylor 2020-11-27 18:37:42 +00:00
parent 5e44d5f75e
commit 9969c928a8

View File

@ -2174,7 +2174,9 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
public function respawn() : void{ public function respawn() : void{
if($this->server->isHardcore()){ if($this->server->isHardcore()){
$this->setBanned(true); 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");
}
return; return;
} }