PlayerPreLoginEvent: New, more elegant way to control authentication requirement

Previously the only way to deal with this was to cancel the PlayerKickEvent generated by lack of authentication. Now, plugins can decide whether auth should be required for a specific player. The default is whatever xbox-auth is set to in server.properties.

cc @Johnmacrocraft
This commit is contained in:
Dylan K. Taylor
2018-12-23 18:24:33 +00:00
parent f313d06070
commit 02efa93e3a
3 changed files with 30 additions and 8 deletions

View File

@ -42,14 +42,18 @@ use pocketmine\Player;
class PlayerPreLoginEvent extends PlayerEvent implements Cancellable{
/** @var string */
protected $kickMessage;
/** @var bool */
protected $authRequired;
/**
* @param Player $player
* @param string $kickMessage
* @param bool $authRequired
*/
public function __construct(Player $player, string $kickMessage){
public function __construct(Player $player, string $kickMessage, bool $authRequired){
$this->player = $player;
$this->kickMessage = $kickMessage;
$this->authRequired = $authRequired;
}
/**
@ -65,4 +69,18 @@ class PlayerPreLoginEvent extends PlayerEvent implements Cancellable{
public function getKickMessage() : string{
return $this->kickMessage;
}
/**
* @return bool
*/
public function isAuthRequired() : bool{
return $this->authRequired;
}
/**
* @param bool $v
*/
public function setAuthRequired(bool $v) : void{
$this->authRequired = $v;
}
}