Can someone help me out here? Every time I go to put my plugin on my server it keeps sending me an error saying, main class not found. Here's the code so far. PHP: <?phpnamespace FlyUI;use pocketmine\Server;use pocketmine\Player;use pocketmine\plugin\PluginBase as Base;use pocketmine\utils\TextFormat as TF;use pocketmine\event\Listener;use pocketmine\command\Command;use pocketmine\command\CommandSender;use jojoe77777\FormAPI;class Main extends Base implements Listener{ public function onEnable(){ $this->getLogger()->info("FlyUI Activated"); $this->getServer()->getPluginManager()->registerEvents($this, $this); } public function onCommand(CommandSender $sender, Command $command, string $label, array $args): bool{ if(strtolower($command->getName()) == "fly"){ if($sender->hasPermission("fly.permission") || $sender->isOp()){ } public function onCommand(CommandSender $sender, Command $cmd, string $label, array $args): bool{ $player = $sender->getPlayer(); switch ($cmd->getName()){ case "fly": $this->mainFrom($player); break; } return true; } public function mainFrom($player){ $plugin = $this->getServer()->getPluginManager(); $formapi = $plugin->getPlugin("FormAPI"); $form = $formapi->createSimpleForm(function (Player $event, array $args){ $result = $args[0]; $player = $event->getPlayer(); if($result === null){ } switch($result){ case 0: return; case 1: $this->enableForm($player); return; case 2: $this->disableForm($player); return; } }); $form->setTitle(TF::BOLD . TF::BLACK . "FlyUI Menu"); $form->setContent(TF::GRAY . "Enable/Disable Fly Mode!"); $form->addButton(TF::GREEN . "Enable"); $form->addButton(TF::RED . "Disable"); $form->addButton(TF::WHITE . "Cancel"); $form->sendToPlayer($player); } public function enableForm($player){ $sender->setAllowFlight(true); $sender->setFlying(true); $sender->addTitle(TF::GREEN . "Fly Mode Enabled"); } public function disabeForm($player){ $sender->setAllowFlight(false); $sender->setFlying(false); $sender->addTitle(TF::RED . "Fly Mode Disabled!"); } }
PHP: name: FlyUI-JazzyDevZmain: JazzyDevZ/Mainversion: 0.0.2api: [3.0.0-ALPHA10]author: JazzyDevZcommands: fly: description: "Sends a form to you that enables fly mode"permissions: fly.permission: default: false
The namespace used in your main(from your plugin.yml) differs from the one in your Main class. Make sure that they reflect an accurate folder structure. The only difference between your value in your Main class and your main key from your plugin.yml is that your plugin.yml contains the class name along with the folder structure, while the namespace in your Main class IS the folder structure. Let me give you an example. Say I had a source plugin labeled TestPlugin. Inside of the TestPlugin folder was a folder labeled "src" and a file labeled "plugin.yml." Inside of the src folder there was a folder labeled "sys" and inside the sys folder contained another folder labeled "jordan." Now, inside of the jordan folder contained the Main file, which in turn contained our Main class. I want to make sure that my plugin loads without any errors, so I'm going to make sure my namespace reflects my folder structure. So since the Main class is inside of the jordan folder and the jordan folder is located in the sys folder, I'm going to label my namespace as "sys\jordan". The best way to describe the namespace is the folders(excluding the src folder) that your PHP file is contained in. Here is what my skeleton class with my namespace would look like: Now, the main in the plugin.yml reflects the namespace plus the class name. I'd hope you realize that when you create a PHP class, the thing that says "class YourClassNameHere" will be your class name. So for my example, Main is my class name. Make sure to NOT put the file extension in the main key contained inside of your plugin.yml. Here is what my plugin.yml looks like: Don't worry about the values under the api key, that's just another way to do arrays. But if I load my plugin, you can see there's no errors and it boots correctly(assuming you have DevTools loaded) I hope this resolves any issues you have, if you have any questions about namespaces, feel free to ask!
Put your plugin on GitHub and let Poggit inspect it. Detecting the main class is probably the only thing Poggit is good at
"namespace FlyUI;" must be "namespace JazzyDevZ. Make sure sure you have in your your folder plugin: (Folder)src -> (Folder)JazzyDevZ -> (PHP File)Main.php (YAML File)plugin.yml
Your plugin.yml must be this: PHP: name: FlyUI-JazzyDevZmain: sys\jordan\Mainversion: 0.0.2api: [3.0.0-ALPHA10]author: JazzyDevZcommands: fly: description: "Sends a form to you that enables fly mode"permissions: fly.permission: default: false
Hey, I am having same error, Can you help me My Plugin Structure >MagicalSBMenu ___>src _______>MuditIsOP _____________>MagicalSBMenu ____________________>Main.php ___>resources __________>config.yml ___>plugin.yml