PHP: switch($cmd->getName()){ case "tests": if($sender instanceof Player){ $sender->sendMessage($sender->getName()/*name of the op player*/ . "message"); return true; } }
PHP: $ops = implode(", ", array_filter($this->getServer()->getOnlinePlayers(), function ($value) { return $value->isOp(); }, ARRAY_FILTER_USE_BOTH)); You can use array_filter and implode functions
What exactly is it that you are trying to accomplish? Are you trying to make it that only an OP can run the command?
PHP: switch($cmd->getName()){ case "tests": if($sender instanceof Player){ $onlinePlayers = $this->getServer()->getOnlinePlayers(); $serverOps = array(); foreach ($onlinePlayers as $player) { if($player->isOp()) { array_push($serverOps, $player->getName()); } } $sender->sendMessage("Online OPS: " . implode(" ",$serverOps) . "MESSAGE"); return true; } } } Im still taking more OOP php courses, so if this code sucks...im trying
PHP: switch($cmd->getName()){ case "test2": if($sender instanceof Player){ $sender->sendMessage("§a StarLitBinkie is connected"); $sender->sendMessage("§4 StarLitBinkie is disconnected"); return true; } } Thanks it's work. How can I display name of player who is connected in green and the name of the same player but he is disconnected in red ?
If you want to do this for offline OPs too, I believe that you will have to store the names off each operator somewhere, then check if the player is online