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

Beginner Plugin Designer Needs a little help!

Comments in 'Plugin Development' started by yungtechboy1, Jan 8, 2015.

  1. yungtechboy1
    Offline

    yungtechboy1 Active Member Plugin Developer

    Joined:
    Dec 25, 2014
    Posts:
    57
    Plugins:
    1
    Minecraft User:
    yungt
    I currently have this code but when I try and call the onPlayerDeath() listener it wont work. Their are very few documentations for problems like this. Please Help me. Tell me what is wrong with my code?!?!?

    Code:
    <?php
    
    namespace CyberTech;
    
    use pocketmine\Player;
    use pocketmine\Server;
    use pocketmine\event\Listener;
    use pocketmine\event\player\PlayerEvent;
    use pocketmine\event\player\PlayerJoinEvent;
    use pocketmine\event\player\PlayerQuitEvent;
    use pocketmine\event\player\PlayerDeathEvent;
    use pocketmine\event\entity\EntityDeathEvent;
    use pocketmine\event\entity\EntityLevelChangeEvent;
    use pocketmine\level\Position;
    use pocketmine\math\Vector3;
    use pocketmine\permission\Permission;
    use pocketmine\plugin\PluginBase;
    use pocketmine\utils\Config;
    use pocketmine\utils\TextFormat;
    
    class Functions extends PluginBase implements Listener{
       
            public function __construct(Main $plugin){
            $this->plugin = $plugin;
        }
       
       
           public function onPlayerDeath(PlayerDeathEvent $event){
        $player = $event->getEntity();   
            $this->getLogger()->info("Arena[1]:".$player);
                    return  $this->getLogger()->info("Arena[1]:".$player);;
        }
       
        public function startfight1($sender, $arena, array $args){
         $this->getLogger()->info("Sender:".$sender);
         $this->getLogger()->info("Arena:".$arena);
         $this->getLogger()->info("Args:".$args[0]);
         $this->getLogger()->info("StartFight has been called!");
          return true;
        }
       
    }
    ?>
    
  2. iksaku
    Offline

    iksaku Notable Member Plugin Developer

    Joined:
    Sep 2, 2013
    Posts:
    1,132
    Plugins:
    4
    Minecraft User:
    iksaku
    Just one question... Are you using an IDE to code?
  3. yungtechboy1
    Offline

    yungtechboy1 Active Member Plugin Developer

    Joined:
    Dec 25, 2014
    Posts:
    57
    Plugins:
    1
    Minecraft User:
    yungt
    lol NutBeans Yes
  4. yungtechboy1
    Offline

    yungtechboy1 Active Member Plugin Developer

    Joined:
    Dec 25, 2014
    Posts:
    57
    Plugins:
    1
    Minecraft User:
    yungt
    lol NutBeans Yes, Why?
  5. hoyinm14mc
    Offline

    hoyinm14mc Notable Member Plugin Developer

    Joined:
    Jun 4, 2014
    Posts:
    502
    Plugins:
    9
    Minecraft User:
    hoyinm14mc
    Nutbeans...
    When I search Nutbeans in google, no such thing!
    It should be NetBeans :p
    jerlegoman and RekkuzaRage like this.
  6. yungtechboy1
    Offline

    yungtechboy1 Active Member Plugin Developer

    Joined:
    Dec 25, 2014
    Posts:
    57
    Plugins:
    1
    Minecraft User:
    yungt
    Lol NetBeans :p
    hoyinm14mc likes this.
  7. EvolSoft
    Offline

    EvolSoft Notable Member Plugin Developer

    Joined:
    Sep 10, 2014
    Posts:
    821
    Plugins:
    15
    Minecraft User:
    Flavius12
    Have you implemented the EventListener in the main class?
  8. yungtechboy1
    Offline

    yungtechboy1 Active Member Plugin Developer

    Joined:
    Dec 25, 2014
    Posts:
    57
    Plugins:
    1
    Minecraft User:
    yungt
    Yes I Have.
    Code:
    use pocketmine\event\Listener;
    
  9. Intyre
    Offline

    Intyre Staff Member PocketMine Team

    Joined:
    Aug 24, 2013
    Posts:
    118
    Minecraft User:
    Intyre
    Code:
    return $this->getLogger()->info("Arena[1]:".$player);;
  10. yungtechboy1
    Offline

    yungtechboy1 Active Member Plugin Developer

    Joined:
    Dec 25, 2014
    Posts:
    57
    Plugins:
    1
    Minecraft User:
    yungt
    Thanks, Hope it works now
  11. yungtechboy1
    Offline

    yungtechboy1 Active Member Plugin Developer

    Joined:
    Dec 25, 2014
    Posts:
    57
    Plugins:
    1
    Minecraft User:
    yungt
    Nope No Luck... I get the OnEnabled And onDisabled to work but not OnPlayerDeath or onPlayerJoin.

    Could someone type out a basic Main.php plugin that said Hi when you join for me?
    So I can try and have a reference to go off of.
  12. yungtechboy1
    Offline

    yungtechboy1 Active Member Plugin Developer

    Joined:
    Dec 25, 2014
    Posts:
    57
    Plugins:
    1
    Minecraft User:
    yungt
    I know you dont have yo have the OnEnable and OnDisable but i just want the onPlayerJoin to happen...
  13. iksaku
    Offline

    iksaku Notable Member Plugin Developer

    Joined:
    Sep 2, 2013
    Posts:
    1,132
    Plugins:
    4
    Minecraft User:
    iksaku
    Do not return anything while you use events! Just put the code
  14. iksaku
    Offline

    iksaku Notable Member Plugin Developer

    Joined:
    Sep 2, 2013
    Posts:
    1,132
    Plugins:
    4
    Minecraft User:
    iksaku
    Did you registered the Class as an event handler?
  15. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    What is this file? Is this the main class of something else? Why did you require a Main parameter in the constructor if it is the main class? Why does it extend PluginBase otherwise?
  16. Humerus
    Offline

    Humerus Staff Member Plugin Reviewer

    Joined:
    Aug 23, 2013
    Posts:
    114
    Plugins:
    1
    The listenter (then functions class) wasn't registered. Please check the documentation for how to do that in the onenable function.
  17. iJoshuaHD
    Offline

    iJoshuaHD Notable Member Plugin Developer

    Joined:
    Nov 7, 2013
    Posts:
    1,201
    Plugins:
    4
    Minecraft User:
    iJoshuaHD
    can u update ur current code because its totally messy or quite wrong.
  18. yungtechboy1
    Offline

    yungtechboy1 Active Member Plugin Developer

    Joined:
    Dec 25, 2014
    Posts:
    57
    Plugins:
    1
    Minecraft User:
    yungt
    THis was my promblem.
  19. iksaku
    Offline

    iksaku Notable Member Plugin Developer

    Joined:
    Sep 2, 2013
    Posts:
    1,132
    Plugins:
    4
    Minecraft User:
    iksaku
    Please upload the WHOLE code to Github and provide us the link to it, so we can help you
  20. kennethgomad
    Offline

    kennethgomad New Member

    Joined:
    Mar 31, 2015
    Posts:
    17
    Minecraft User:
    kennethgomad
    public function not work if there was 4 lines

Share This Page

Advertisement