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

Using class EntityDamageByEntityEvent

Comments in 'Plugin Development' started by WinniePooh, Oct 7, 2014.

  1. WinniePooh
    Offline

    WinniePooh New Member

    Joined:
    Jun 12, 2014
    Posts:
    16
    Minecraft User:
    WinniePooh
    So, when I'm shooting an arrow, there is a server crash. Here are a mistake and my code. And I haven't got any ideas for solution.
    I need a player who causes damage to another player. Class EntityDamageByEntityEvent has got method getDamager(), but class EntityDamageEvent hasn't got it.

    PHP:
    public function onEntityDamageByEntity(EntityDamageByEntityEvent $evt) {
            
    $player $evt->getDamager();      
        }
    Code:
    23:03:25 [NOTICE] An E_RECOVERABLE_ERROR error happened: "Argument 1 passed to WinniePooh\WorldGuard\Main::onEntityDamageByEntity() must be an instance of pocketmine\event\entity\EntityDamageByEntityEvent, instance of pocketmine\event\entity\EntityDamageEvent given, called in /root/pm1.4/src/pocketmine/plugin/MethodEventExecutor.php on line 36 and defined" in "/plugins/worldguard_HC/src/WinniePooh/WorldGuard/Main" at line 205
    
    Fatal error: Call to undefined method pocketmine\event\entity\EntityDamageEvent::getDamager() in /root/pm1.4/plugins/worldguard_HC/src/WinniePooh/WorldGuard/Main.php on line 88
    23:03:25 [EMERGENCY] An unrecoverable error has occurred and the server has crashed. Creating a crash dump
    23:03:25 [EMERGENCY] Please submit the "/root/pm1.4/CrashDump_Tue_Oct_7-23.03.25-MSK_2014.log" file to the Bug Reporting page. Give as much info as you can.
    
    I'm sorry for my english.
  2. WinniePooh
    Offline

    WinniePooh New Member

    Joined:
    Jun 12, 2014
    Posts:
    16
    Minecraft User:
    WinniePooh
    Thx for LDX. I think it isn't the best solution but there isn't any analogues. Here is a link: http://forums.pocketmine.net/posts/58135/
    And code:

    PHP:
     public function onFight(EntityDamageEvent $event) {  
         if(
    $event instanceof EntityDamageByEntityEvent && $event->getDamager() instanceof Player) {
            
    $d $event->getDamager();            
        }
      }
    LDX likes this.
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    It is the best solution because you can't hook to EntityDamageByEntityEvent because it has no static property $handlerList.
    Legoboy0215 and LDX like this.

Share This Page

Advertisement