mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 17:59:48 +00:00
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:
@ -59,6 +59,8 @@ class ProcessLoginTask extends AsyncTask{
|
||||
* root public key.
|
||||
*/
|
||||
private $authenticated = false;
|
||||
/** @var bool */
|
||||
private $authRequired;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
@ -74,9 +76,10 @@ class ProcessLoginTask extends AsyncTask{
|
||||
/** @var string|null */
|
||||
private $handshakeJwt = null;
|
||||
|
||||
public function __construct(Player $player, LoginPacket $packet, bool $useEncryption = true){
|
||||
public function __construct(Player $player, LoginPacket $packet, bool $authRequired, bool $useEncryption = true){
|
||||
$this->storeLocal($player);
|
||||
$this->packet = $packet;
|
||||
$this->authRequired = $authRequired;
|
||||
$this->useEncryption = $useEncryption;
|
||||
if($useEncryption){
|
||||
if(self::$SERVER_PRIVATE_KEY === null){
|
||||
@ -220,7 +223,7 @@ class ProcessLoginTask extends AsyncTask{
|
||||
$player = $this->fetchLocal();
|
||||
if(!$player->isConnected()){
|
||||
$this->worker->getLogger()->error("Player " . $player->getName() . " was disconnected before their login could be verified");
|
||||
}elseif($player->setAuthenticationStatus($this->authenticated, $this->error)){
|
||||
}elseif($player->setAuthenticationStatus($this->authenticated, $this->authRequired, $this->error)){
|
||||
if(!$this->useEncryption){
|
||||
$player->getNetworkSession()->onLoginSuccess();
|
||||
}else{
|
||||
|
Reference in New Issue
Block a user