diff --git a/changelogs/4.0-snapshot.md b/changelogs/4.0-snapshot.md index 9193de3e5..94354649c 100644 --- a/changelogs/4.0-snapshot.md +++ b/changelogs/4.0-snapshot.md @@ -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`. diff --git a/src/player/IPlayer.php b/src/player/IPlayer.php index 607033f5d..c5c8430c9 100644 --- a/src/player/IPlayer.php +++ b/src/player/IPlayer.php @@ -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; diff --git a/src/player/OfflinePlayer.php b/src/player/OfflinePlayer.php index a484a4c75..8aa42c998 100644 --- a/src/player/OfflinePlayer.php +++ b/src/player/OfflinePlayer.php @@ -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); } diff --git a/src/player/Player.php b/src/player/Player.php index 46fc4385e..708a25109 100644 --- a/src/player/Player.php +++ b/src/player/Player.php @@ -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; }