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

No Errors but when i /pl it shows red.

Discussion in 'Development' started by Vaxrp, Oct 11, 2017.

  1. Vaxrp

    Vaxrp Witch

    Messages:
    73
    GitHub:
    Vaxrp
    Code:
    <?php
    
    namespace Soup;
    
    use pocketmine\event\player\PlayersInteractEvent;
    use pocketmine\event\entity\EntityDamageEvent;
    use pocketmine\event\entity\EntityDamageByEntityEvent;
    use pocketmine\event\Listener;
    
    use pocketmine\plugin\PluginBase;
    use pocketmine\Server;
    use pocketmine\Player;
    
      class Main extends PluginBase implements Listener{
    
        public function onEnable() {
        $this->getServer()->getPluginManager()->registerEvents($this,$this);
         
        }
       
        public function onInteract(PlayerInteractEvent $event) {
       
        $player = $event->getPlayer();
        $item = $event->getItem();
         if($item->getId() === Item::MUSHROOM_STEW){
          $player->getInventory()->removeItem($item);
          $player->setHealth($player->getHealth() + 5);
          $player->setFood(20);
         }
         
        }
      }
    
    This is what I used for a “ Soup Heal Plugin”. I get 0 console errors but the plugin still wont enable not sure what I did wrong as I am new to this stuff.
     
  2. McpeBooster

    McpeBooster Baby Zombie

    Messages:
    190
    GitHub:
    mcpebooster
    Are you sure there is no error?
    Do you have the plugin.yml correct?
     
  3. QuiverlyRivalry

    QuiverlyRivalry Zombie Pigman

    Messages:
    491
    GitHub:
    quiverlyrivalry
    You have to add on on enable and on load on disable and etc?
     
  4. McpeBooster

    McpeBooster Baby Zombie

    Messages:
    190
    GitHub:
    mcpebooster
    no, you dont need onLoad() or onDisable()
     
  5. rektpixel

    rektpixel Baby Zombie

    Messages:
    186
    wow very strange. I've never had this error before. It doesn't even show why it didn't loaded :eek:
     

    Attached Files:

  6. Awzaw

    Awzaw Zombie Pigman Poggit Admin

    Messages:
    726
    GitHub:
    awzaw
    PlayersInteractEvent? Use an IDE and you won't miss mistakes like that.
     
    rektpixel likes this.
  7. McpeBooster

    McpeBooster Baby Zombie

    Messages:
    190
    GitHub:
    mcpebooster
    Facepalm :D
     
    rektpixel likes this.
  8. Vaxrp

    Vaxrp Witch

    Messages:
    73
    GitHub:
    Vaxrp
    I got the plugin enabled I fixed the PlayerInteractEvent but now the actual plugin wont work. When I tap soup on floor it doesnt do anything. This is the only way I could think of getting Mushroom_Stew to heal. any help?
     
  9. McpeBooster

    McpeBooster Baby Zombie

    Messages:
    190
    GitHub:
    mcpebooster
    you should add a
    PHP:
    use pocketmine\item\Item;
     
    rektpixel and iiFlamiinBlaze like this.
  10. iiFlamiinBlaze

    iiFlamiinBlaze Witch

    Messages:
    59
    GitHub:
    iiflamiinblaze
    Show us your plugin.yml and do you have the main.php file in the src folder?
     
  11. Vaxrp

    Vaxrp Witch

    Messages:
    73
    GitHub:
    Vaxrp
    Yup that did it. thanks. Im new so I forget stuff or make silly mistakes
     
  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.