From ca7c23c137844adbb566b5a160c9957a0159e978 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 8 May 2019 19:47:25 +0100 Subject: [PATCH] Player: remove dead functions these functions belong in the network session, and they are currently just proxies for them. In the future we might have players who don't have IPs at all depending on how they connected (for example Specter) so this stuff shouldn't be in here. --- src/pocketmine/Player.php | 26 ------------------- .../command/defaults/BanIpCommand.php | 4 +-- 2 files changed, 2 insertions(+), 28 deletions(-) diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 15eb4a57b..fa90bc91f 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -849,32 +849,6 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener, parent::sendSkin($targets ?? $this->server->getOnlinePlayers()); } - /** - * Gets the player IP address - * - * @return string - */ - public function getAddress() : string{ - return $this->networkSession->getIp(); - } - - /** - * @return int - */ - public function getPort() : int{ - return $this->networkSession->getPort(); - } - - /** - * Returns the last measured latency for this player, in milliseconds. This is measured automatically and reported - * back by the network interface. - * - * @return int - */ - public function getPing() : int{ - return $this->networkSession->getPing(); - } - /** * Returns whether the player is currently using an item (right-click and hold). * @return bool diff --git a/src/pocketmine/command/defaults/BanIpCommand.php b/src/pocketmine/command/defaults/BanIpCommand.php index c27b65221..6f10b192d 100644 --- a/src/pocketmine/command/defaults/BanIpCommand.php +++ b/src/pocketmine/command/defaults/BanIpCommand.php @@ -62,7 +62,7 @@ class BanIpCommand extends VanillaCommand{ Command::broadcastCommandMessage($sender, new TranslationContainer("commands.banip.success", [$value])); }else{ if(($player = $sender->getServer()->getPlayer($value)) instanceof Player){ - $ip = $player->getAddress(); + $ip = $player->getNetworkSession()->getIp(); $this->processIPBan($ip, $sender, $reason); Command::broadcastCommandMessage($sender, new TranslationContainer("commands.banip.success.players", [$ip, $player->getName()])); @@ -80,7 +80,7 @@ class BanIpCommand extends VanillaCommand{ $sender->getServer()->getIPBans()->addBan($ip, $reason, null, $sender->getName()); foreach($sender->getServer()->getOnlinePlayers() as $player){ - if($player->getAddress() === $ip){ + if($player->getNetworkSession()->getIp() === $ip){ $player->kick($reason !== "" ? $reason : "IP banned."); } }