hello pmmp community , in old api [3.0.0alpha12] if I do that : PHP: <?phpnamespace test;use pocketmine\command\Command;use pocketmine\command\CommandSender;use pocketmine\plugin\PluginBase;class Main extends PluginBase{ public function onEnable() { $this->ANYTHING = "blabla"; } public function onCommand(CommandSender $sender, Command $cmd, string $label, array $args): bool { switch ($cmd->getName()) { case 'a': $sender->sendMessage("$this->ANYTHING"); break; } }} the message will be send but in new api [3.0.2] if I add any thing in $this->ANYTHING var it doesnt work in another function how can I solve that ??
Dont do PHP: $sender->sendMessage("$this->ANYTHING"); Instead, make it like this PHP: $sender->sendMessage($this->ANYTHING); Because ANYTHING is already a string so you dont have to put a string inside a string, also try this, under the class extends PluginBase write its public variable: PHP: public/private $ANYTHING;
Just a tip, but you can do this: PHP: $string = "{$this->ANYTHING}"; too. I know it might seem irrelevant, but it can turn out helpful sometimes when you have multiple inline expressions.
Your plugin is not enabled and the class hasn't been loaded. If the plugin would have enabled, you'd get an error regarding the return value of onCommand(). You haven't given sufficient information for us to debug your code. There has to be something going on in the console which should give you a hint.