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

Could not pass

Comments in 'Plugin Development' started by Skullex, May 1, 2016.

  1. Skullex
    Offline

    Skullex Active Member

    Joined:
    Nov 14, 2015
    Posts:
    212
    Minecraft User:
    Skullex
    I don't know what I did wrong, can you help

    Error -
    Code:
    [Server thread/CRITICAL]: "Could not pass event 'pocketmine\event\player\PlayerDeathEvent' to 'MoneyTag v1': Call to a member function myMoney() on unknown on MoneyTag\Main
    [20:21:27] [Server thread/CRITICAL]: Error: "Call to a member function myMoney() on unknown" (EXCEPTION) in "/MoneyTag-master/src/MoneyTag/Main" at line 64
    
    PHP -
    PHP:
    <?php

    namespace MoneyTag;

    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\utils\TextFormat as TF;
    use 
    pocketmine\event\player\PlayerJoinEvent;
    use 
    pocketmine\event\player\PlayerDeathEvent;
    use 
    pocketmine\event\player\PlayerQuitEvent;
    use 
    pocketmine\event\entity\EntityDamageEvent;
    use 
    pocketmine\event\entity\EntityDamageByEntityEvent;
    use 
    pocketmine\event\entity\EntityDamageByChildEntityEvent;
    use 
    pocketmine\command\Command;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\Server;
    use 
    onebone\economyapi\EconomyAPI;
    use 
    pocketmine\Player;

    class 
    Main extends PluginBase Implements Listener {
        public 
    $economyAPI null;
        public 
    $damagetracker = [ ];
       
        public function 
    onEnable(){
            
    $this->getServer()->getPluginManager()->registerEvents($this$this);
            if(
    $this->getServer ()->getPluginManager()->getPlugin("EconomyAPI") != null){
                
    $this->economyAPI = \onebone\economyapi\EconomyAPI::getInstance();
            }else{
                
    $this->getLogger()->error(TF::RED."There is no EconomyAPI present...");
                
    $this->getServer()->getPluginManager()->disablePlugin($this);
        }
        }
       
        public function 
    onCommand(CommandSender $senderCommand $command$label, array $args){
                 switch(
    $command->getName()){
                          case 
    "coins":
                    
    $money $economyAPI->myMoney($event->getPlayer());
                    
    $name $player->getName();
                    
    $all $this->getServer()->getOnlinePlayers();
                case 
    "coins":
                    
    $player->sendMessage(TF::GOLD."[".TF::YELLOW." $ ".TF::GOLD."] ".TF::GREEN."You have".TF::AQUA.$moneyTF::GOLD." Sky".TF::GREEN." coins");
                  }
        }
       
        public function 
    onJoin(PlayerJoinEvent $event){
            
    $player $event->getPlayer();
            
    $money $economyAPI->myMoney($event->getPlayer());
            
    $name $player->getName();
            
    $all $this->getServer()->getOnlinePlayers();
            
    $player->setNameTag(TF::GREY."[ ".TF::YELLOW.$moneyTF::GREY." ] ".TF::GOLD .$name."");
            
    $player->setDisplayName(TF::GREY."[ ".TF::YELLOW.$moneyTF::GREY." ] ".TF::GOLD .$name."");
        }
       
        public function 
    onDamage(EntityDamageEvent $event) {
            if(
    $event instanceof EntityDamageByEntityEvent or $event instanceof EntityDamageByChildEntityEvent){
                if(
    $event->getDamager() instanceof Player and $event->getEntity() instanceof Player){
                    
    $this->damagetracker [$event->getEntity()->getName()] = $event->getDamager()->getName();
                }
            }
        }
               
        public function 
    onDeath(PlayerDeathEvent $event){
            
    $player $event->getPlayer();
            
    $money $economyAPI->myMoney($event->getPlayer());
            
    $name $player->getName();
            
    $all $this->getServer()->getOnlinePlayers();
            if(isset (
    $this->damagetracker [$event->getEntity()->getName()])){
                
    $damager $this->getServer()->getPlayerExact($this->damagetracker [$event->getEntity()->getName()]);
                if (! 
    $damager instanceof Player) return;
                
    $damager->setNameTag(TF::GREY."[ ".TF::YELLOW.$moneyTF::GREY." ] ".TF::GOLD .$name."");
                
    $damager->setDisplayName(TF::GREY."[ ".TF::YELLOW.$moneyTF::GREY." ] ".TF::GOLD .$name."");
                unset (
    $this->damagetracker [$event->getEntity()->getName()]);
            }
        }
    }
  2. minebuilder0110
    Offline

    minebuilder0110 Notable Member

    Joined:
    Dec 8, 2014
    Posts:
    485
    Minecraft User:
    Apparitional
    Perhaps the usage is wrong?
    PHP:
    use onebone\economyapi\EconomyAPI;
    ...
    ...
    ...
    EconomyAPI::getInstance()->myMoney($player);
    Skullex and Primus like this.
  3. HotFireyDeath
    Offline

    HotFireyDeath Notable Member Plugin Developer

    Joined:
    Mar 19, 2015
    Posts:
    328
    Plugins:
    1
    Minecraft User:
    HotFireyDeath
    When you called myMoney(), it is:
    $economyAPI->myMoney().

    Meanwhile,
    you stored the instance of EconomyAPI in $this->economyAPI.

    So,
    PHP:
    $this->economyAPI->myMoney();
    #and not...
    $economyAPI->myMoney();
    Skullex and Primus like this.
  4. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    And this all leads to one simple sentence "Learn PHP"

Share This Page

Advertisement