1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Main class not found. *Facepalm incomming*

Discussion in 'Facepalm' started by Daniel Pereira, Mar 6, 2018.

  1. Daniel Pereira

    Daniel Pereira Silverfish

    Messages:
    22
    GitHub:
    Undentified
    Hello. I see that you had to click on this Facepalm thread. Well NOW THERE WILL BE CONSEQUENCES. You will need to find why I can't get my plugin on my server which is "Main class not found" but I don't understand since I think I'm saying where it is in plugin.yml the path to it! Painfull to watch right?


    PHP!
    PHP:
    namespace pmmp\learninghere;

    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\plugin\PlayerJoinEvent;
    use 
    pocketmine\Player;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\utils\TextFormat;
    use 
    pocketmine\command\Command;
    use 
    pocketmine\command\CommandSender;

    class 
    Main extends PluginBase implements Listener {

                public function 
    onEnable {
                  
    $this-getServer()->getPluginManager()->registerEvents($this$this);
                  
    $this->getLogger()->Info("Tutorial Enabled.");
                }
                public function 
    onDisable {
                  
    $this->getLogger()->Info("Tutorial Disabled.");
                }


                  public function 
    playerJoinEvent(PlayerJoinEvent $event) {
                    
    $player $event->getPlayer();

                    if (
    $player hasPlayedBefore() == true) {
                      
    $player->sendMessage(TextFormat::GOLD "Welcome back!");
                    } else {
                      
    $world $this->getServer()->getLevelByName("tutorial");
                      
    $player->teleport($world);
                      
    $player->sendMessage(TextFormat::GOLD "Welcome Adventurer to Swords & Castles. Let's start with a brief tutorial.");
                      
    $player->sendMessage(TextFormat::GOLD "If you wish to leave the Tutorial please do /leave");
                    }
                  }

                  public function 
    onCommand(CommandSender $senderCommand $command$label, array $args) {
                        switch (
    $command->getName()) {
                          case 
    "leave":
                          
    $mainworld "world";
                            
    $sender-teleport($mainworld);
                          return 
    true;
    YML
    Code:
    name: learning
    main: pmmp/learninghere/Main
    version: 0.1
    api: 3.0.0-ALPHA11
    description: Tutorial Plugin for Swords & Castles made by Nortuno with pmmp forums support.
    author: Nortuno
    
    commands:
      leave:
        description: "Leaves the Tutorial"
        usage: "/leave"
    

    File Structure:

    [Learning]
    {plugin.yml} + [src]
    [pmmp]
    [learninghere]
    {Main.php}
     
  2. LewBr

    LewBr Zombie

    Messages:
    385
    GitHub:
    lewbr
    PHP:
    pmmp/learninghere/Main
    to
    PHP:
    pmmp\learninghere\Main
    on plugin.yml
     
  3. SJames

    SJames Spider Jockey

    Messages:
    35
    GitHub:
    sjamese
    And you need <?php at the begging of the main file. Hope it works :)
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.