Hi! I'm cracking my head on this one plugin. Any help would be appreciated... My Error: PHP: [14:02:21] [Server thread/CRITICAL]: Error: "Call to undefined method RTG\GitHub\Review::setExecutor()" (EXCEPTION) in "/Review/src/RTG/GitHub/Review" at line 23 My Loader on where its causing it from: PHP: public function onEnable() { @mkdir($this->getDataFolder()); @mkdir($this->getDataFolder() . "/players"); $this->getLogger()->info("[Review] DIR has been made!"); $this->getLogger()->info("Loaded!"); /* Execution */ $this->setExecutor(new MyCommand($this)); - Line 23 $this->getLogger()->info("[Review] Everything has been loaded!"); }
Nope, I'll attach my full Review.php and MyCommand.php PHP: <?phpnamespace RTG\GitHub;/* * All rights reserved RTGNetworkkk *//* Essentials */use pocketmine\Player;use pocketmine\Server;use pocketmine\plugin\PluginBase;class Review extends PluginBase { public function onEnable() { @mkdir($this->getDataFolder()); @mkdir($this->getDataFolder() . "/players"); $this->getLogger()->warning("[Review] DIR has been made!"); $this->getLogger()->warning("Loaded!"); /* Execution */ $this->setExecutor(new MyCommand($this)); $this->getLogger()->warning("[Review] Everything has been loaded!"); } public function onDisable() { } } MyCommand: PHP: <?phpnamespace RTG\GitHub\Command;use pocketmine\command\Command;use pocketmine\command\CommandSender;use pocketmine\command\CommandExecutor;use pocketmine\utils\Config;use RTG\GitHub\Review;use pocketmine\utils\TextFormat as TF;class MyCommand implements CommandExecutor { public function __construct(Review $plugin) { $this->plugin = $plugin; } public function onCommand(CommandSender $sender, Command $cmd, $label, array $param) { switch($cmd->getName()) { case "review": if(isset($param[0])) { switch($param[0]) { case "add": if($sender->hasPermission("review.add")) { $n = $sender->getName(); if(count($param) < 1) return false; $msg = trim(implode(" ", $param)); $this->cfg = new Config($this->getDataFolder() . "/players" . $n . "yml", Config::YAML); $this->cfg->setNested($msg); $sender->sendMessage("[Review] You review has been added!"); } else { $sender->sendMessage(TF::RED . "You have no permission to use this command!"); } return true; break; } } else { $sender->sendMessage("Usage: /review add {review}"); } return true; break; } } }
Your class has to extend PluginCommand if you want to set the executor. You need to create a third class extending PluginCommand.
The solution is really easy. Just make that line: PHP: $this->getCommand("review")->setExecutor(blablabla);
It worked, Thanks PHP: [14:35:08] [Server thread/WARNING]: [Reviewer] [Review] DIR has been made![14:35:08] [Server thread/WARNING]: [Reviewer] Loaded![14:35:08] [Server thread/WARNING]: [Reviewer] [Review] Everything has been loaded!
That worked I know this is wrong PHP: $this->cfg = new Config($this->plugin->getDataFolder() . "/players" . $n . "yml", Config::YAML); because i didnt add "pocketmine\utils\Config" xD
I don't know why I see this, but shouldn't you use $this->getLogger()->notice() instead of $this->getLogger()->warning() unless you are displaying errors?
I would like to apologize for being irrelevant or annoying. I was simply trying to point out something that might inform you or another developer if you choose to acknowledge it, that $this->getLogger->warning() outputs a message that appears as an error, which may be misleading to somebody using the plugin.