Hey i have seeing quickly the forum but all threads for my case is not detailed enough for me because 1. i'm french 2.I'm start in the development My case is i want to get all args for my plugin broadcaster the usage is /br message PHP: class broadcast extends command { private $us = "/br messag to broadcast"; public function execute(CommandSender $sender, $command, array $args){if($sender->isOp()) {if(count($args) == 0) {$sender->sendMessage("WELCOME the usage is $us please to do a space do just !sp");}elseif (count($args) == 1) { $msg = $args[0]; $nw = str_replace("!sp", " ", $msg); $pal = TextFormat::GREEN . "[Announce] " . TextFormat::WHITE . $nw; $sender->getServer()->broadcastMessage($pal, null);}else { $sender->sendMessage("WELCOME the usage is $us please to do a space do just !sp");}}else{ return false; }}} i use the str replace because i don't know how to get all args AND sorry for my english i'm french
You code is broken, a lot. PHP: public function __construct() { $this->setUsage("/br <...message>");}public function execute(CommandSender $sender, $label, array $args) { if(!$this->testPermission($sender)) return false; if(empty($args)) return false; $sender->getServer()->broadcastMessage(TextFormat::GREEN . "[Announce] " . implode(" ", $args)); return true;}
Yes I know But For me Just they work is good I have seeing i'm starting in Development so I Do lot of error But my code work for me isn't problem
yes i know you will prefer to use what you are comfortable with but sometimes it is best to make it more "proper"
No problem also our forum are moving to https://forums.pmmp.gq/ so sooner then latter it will be abandoned