PHP: public function onCommand(CommandSender $sender, Command $cmd, $label, array $args) { $fcmd = $cmd->getName(); # Get command name if(strtolower($fcmd) === "command"){ # Check if he is executing /command if(isset($args[0])){ # /command <this is args[0]> <this is args[1]> etc... $player = $this->plugin->getServer()->getPlayer($args[0]); # The string args[0] will be a Player object. if($player instanceof Player){ # Check if it's a valid player. $sender->sendMessage($player->getName() . " address is " . $player->getAddress()); } } } }
I know the difference. I am using !empty() because it still returns false even when I only have Spaces in the command, while isset() returns true
But in that case, what about this command? Code: /cmd something $args[0] is empty but isset. But you may make it impossible to detect the second argument. Sometimes, these things are done on purpose