I wanted to perform some event with the Player that was informed in $args[0], I tried to use this but it did not give... public function execute(CommandSender $sender, $label, array $args){ if(!isset($args[0])){ $sender->sendMessage("Use: /test <player>"); return true; } $player = $this->pl->getServer()->getPlayer($args[0]); if($args[0] == $player){ $player->sendMessage("TEST"); } }
You don't need verify this, only do: PHP: if(!is_null($player)){ # IF PLAYER IS ONLINE $player->sendMessage("TEST");}else{$sender->sendMessage("Player offline");}
PHP: $user = $args[1];$target = Server::getInstance()->getPlayer($user);if ($target == null) {$sender->sendMessage("§c{$user} is offline.");} else {//do what you want} that should work