mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 17:59:48 +00:00
Strip some junk out of IPlayer
these methods have better pathways through Server directly. Also, setBanned() does not allow customising the reason for banning or the duration, nor does isBanned() account for IP bans because the code is so old ... better to force dependence on a central code path to avoid these inconsistencies. I want to do the same thing for OP, but that's a separate problem due to its effects on the permission system.
This commit is contained in:
@ -31,14 +31,6 @@ interface IPlayer extends ServerOperator{
|
||||
|
||||
public function getName() : string;
|
||||
|
||||
public function isBanned() : bool;
|
||||
|
||||
public function setBanned(bool $banned) : void;
|
||||
|
||||
public function isWhitelisted() : bool;
|
||||
|
||||
public function setWhitelisted(bool $value) : void;
|
||||
|
||||
public function getFirstPlayed() : ?int;
|
||||
|
||||
public function getLastPlayed() : ?int;
|
||||
|
@ -70,30 +70,6 @@ class OfflinePlayer implements IPlayer{
|
||||
}
|
||||
}
|
||||
|
||||
public function isBanned() : bool{
|
||||
return $this->server->getNameBans()->isBanned($this->name);
|
||||
}
|
||||
|
||||
public function setBanned(bool $banned) : void{
|
||||
if($banned){
|
||||
$this->server->getNameBans()->addBan($this->name, null, null, null);
|
||||
}else{
|
||||
$this->server->getNameBans()->remove($this->name);
|
||||
}
|
||||
}
|
||||
|
||||
public function isWhitelisted() : bool{
|
||||
return $this->server->isWhitelisted($this->name);
|
||||
}
|
||||
|
||||
public function setWhitelisted(bool $value) : void{
|
||||
if($value){
|
||||
$this->server->addWhitelist($this->name);
|
||||
}else{
|
||||
$this->server->removeWhitelist($this->name);
|
||||
}
|
||||
}
|
||||
|
||||
public function getPlayer() : ?Player{
|
||||
return $this->server->getPlayerExact($this->name);
|
||||
}
|
||||
|
@ -368,31 +368,6 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
||||
return "";
|
||||
}
|
||||
|
||||
public function isBanned() : bool{
|
||||
return $this->server->getNameBans()->isBanned($this->username);
|
||||
}
|
||||
|
||||
public function setBanned(bool $banned) : void{
|
||||
if($banned){
|
||||
$this->server->getNameBans()->addBan($this->getName(), null, null, null);
|
||||
$this->kick("You have been banned");
|
||||
}else{
|
||||
$this->server->getNameBans()->remove($this->getName());
|
||||
}
|
||||
}
|
||||
|
||||
public function isWhitelisted() : bool{
|
||||
return $this->server->isWhitelisted($this->username);
|
||||
}
|
||||
|
||||
public function setWhitelisted(bool $value) : void{
|
||||
if($value){
|
||||
$this->server->addWhitelist($this->username);
|
||||
}else{
|
||||
$this->server->removeWhitelist($this->username);
|
||||
}
|
||||
}
|
||||
|
||||
public function isAuthenticated() : bool{
|
||||
return $this->authenticated;
|
||||
}
|
||||
|
Reference in New Issue
Block a user