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:
Dylan K. Taylor 2020-11-28 15:36:46 +00:00
parent 70b0d83258
commit 8cf589eedd
4 changed files with 4 additions and 58 deletions

View File

@ -597,7 +597,10 @@ This version features substantial changes to the network system, improving coher
- `Player->updatePing()`: moved to `NetworkSession`
- `Player->dataPacket()`: replaced by `NetworkSession->sendDataPacket()`
- `Player->sendDataPacket()`: replaced by `NetworkSession->sendDataPacket()`
- `IPlayer->isWhitelisted()`: use `Server->isWhitelisted()` instead
- `IPlayer->setWhitelisted()`: use `Server->setWhitelisted()` instead
- `IPlayer->isBanned()`: this was unreliable because it only checked name bans and didn't account for plugin custom ban systems. Use `Server->getNameBans()->isBanned()` and `Server->getIPBans()->isBanned()` instead.
- `IPlayer->setBanned()`: use `Server` APIs instead
### Plugin
- API version checks are now more strict. It is no longer legal to declare multiple minimum versions on the same major version. Doing so will now cause the plugin to fail to load with the message `Multiple minimum API versions found for some major versions`.

View File

@ -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;

View File

@ -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);
}

View File

@ -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;
}