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

My plugin doesen't work :(

Comments in 'Plugin Development' started by ButterCoder, Jun 19, 2015.

  1. ButterCoder
    Offline

    ButterCoder New Member

    Joined:
    Jun 18, 2015
    Posts:
    8
    Minecraft User:
    ButterCoder
    Hi I started to work on a plugin and it was working and I did something with it (I don't know what)
    and now its not working. I'm using the new api for 0.11.0 .

    PHP:
    <?php

    namespace ButterPack;


    use 
    pocketmine\Player;
    use 
    pocketmine\Entity;
    use 
    pocketmine\Server;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\event\player\PlayerInteractEvent;







    class 
    Main extends PluginBase implements Listener{
      


        public function 
    onEnable(){
            
    $this->getLogger()->info("ButterPack enabled");
        }
      
        public function 
    onDisable(){
            
    $this->getLogger()->info("ButterPack disabled");
        }


      
        class 
    PlayerListener implements Listener{
                public function 
    onPlayerInteract(PlayerInteractEvent $event) {
                if(
    $event->getItem()->getId() === 280){
                    if(
    $event->getBlock()->getId() === 1){
                        if(
    $event->getFace() === 1){
                            
    $this->getLogger()->info(" Touched stone" );
                          
                          
                          
                          
                          
                          
                          
                          
                        }
                    }
                }
            }
          
        }

      
      

      

      

    }
  2. EvolSoft
    Offline

    EvolSoft Notable Member Plugin Developer

    Joined:
    Sep 10, 2014
    Posts:
    821
    Plugins:
    15
    Minecraft User:
    Flavius12
    First of all, if you want to handle events in PlayerListener class why did you implement the Listener interface also in the main class?
    Second: you forgot to register events
    PEMapModder, ButterCoder and Xenturio like this.
  3. ButterCoder
    Offline

    ButterCoder New Member

    Joined:
    Jun 18, 2015
    Posts:
    8
    Minecraft User:
    ButterCoder
    I removed the player listener class, what events a forgot to register. (I'm new to plugin developing and php)
  4. Xenturio
    Offline

    Xenturio Active Member

    Joined:
    Sep 19, 2014
    Posts:
    333
    Minecraft User:
    Xenturio
    PHP:
            public function onEnable()
            {
                
    $this->getServer()->getPluginManager()->registerEvents($this,$this);
            }
    without that no events will be called
    ButterCoder likes this.
  5. ButterCoder
    Offline

    ButterCoder New Member

    Joined:
    Jun 18, 2015
    Posts:
    8
    Minecraft User:
    ButterCoder
    Thank you!
    Xenturio likes this.
  6. Xenturio
    Offline

    Xenturio Active Member

    Joined:
    Sep 19, 2014
    Posts:
    333
    Minecraft User:
    Xenturio
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    PHP doesn't have anonymous/inner classes :(

Share This Page

Advertisement