Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

class error

Comments in 'Plugin Development' started by Artide, May 3, 2015.

  1. Artide
    Offline

    Artide Active Member

    Joined:
    Apr 20, 2015
    Posts:
    214
    Minecraft User:
    Artide5
    Uggh, I suck at php, please help, I don't know what I did wrong but it says the class is wrong.
    PHP:
    <?php

    namespace JoinSpawn;

    use 
    pockemine\Player;
    use 
    pocketmine\level\Level;
    use 
    pocketmine\event\player\PlayerJoinEvent;
    use 
    pocketmine\plugin\PluginBase;

    class 
    Main extends PluinBase{

    public function 
    onEnable(){

        
    $this->getLogger()->info("Everything loaded!");

    }

    public function 
    onJoin(PlayerJoinEvent $event){

      
    $p $event->getPlayer();

      
    $p->teleport($this->getServer()->getDefaultLevel()->getSpawn());
       
    }

    public function 
    onDisable(){
     
      
    $this->getLogger()->info("Plugin unloaded!");

    }

    }
    ?>
  2. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    PHP:
    <?php

    namespace JoinSpawn// Should be yourname\Pluginname;

    use pockemine\Player;
    use 
    pocketmine\level\Level;
    use 
    pocketmine\event\player\PlayerJoinEvent;
    use 
    pocketmine\plugin\PluginBase;

    class 
    Main extends PluginBase//Typo in PluginBase

    public function onEnable(){

        
    $this->getLogger()->info("Everything loaded!");

    }

    public function 
    onJoin(PlayerJoinEvent $event){

      
    $p $event->getPlayer();

      
    $p->teleport($this->getServer()->getDefaultLevel()->getSpawn());
      
    }

    public function 
    onDisable(){
      
    $this->getLogger()->info("Plugin unloaded!");

    }

    }
    // no ?> needed
  3. Artide
    Offline

    Artide Active Member

    Joined:
    Apr 20, 2015
    Posts:
    214
    Minecraft User:
    Artide5
    Oops :eek:
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Author name isn't necessary in namespace.
  5. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Yea but isn't that the Class Path most time?
  6. Artide
    Offline

    Artide Active Member

    Joined:
    Apr 20, 2015
    Posts:
    214
    Minecraft User:
    Artide5
    Ahh! it doesn't work, Its supposed to teleport me to default spawn when I join. :eek:
  7. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    PHP:
    $p->teleport($this->getServer()->getDefaultLevel()->getDefaultSpawn()); // Should be this
  8. Artide
    Offline

    Artide Active Member

    Joined:
    Apr 20, 2015
    Posts:
    214
    Minecraft User:
    Artide5
    Thank you!! It works :)
  9. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit

Share This Page

Advertisement