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

Solved EntityDamageByEntityEvent Error

Comments in 'Plugin Development' started by Legoboy0215, Jul 4, 2015.

  1. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Here is the code:
    PHP:
      public function onHurtCMode(EntityDamageByEntityEvent $event){
          
    $hurter $event->getDamager();
          if(
    $hurter->getGamemode() == 1){
            
    $event->setCancelled(true);
            
    $hurter->sendMessage(TextFormat::RED "No creative mode killing please!");
        }
    }
    And here is the error:
    PHP:
    Could not pass event 'pocketmine\event\entity\EntityDamageEvent' to 'EventHandler v1.0.0'Argument 1 passed to EH\Main::onHurtCMode() must be an instance of pocketmine\event\entity\EntityDamageByEntityEventinstance of pocketmine\event\entity\EntityDamageEvent givencalled in phar:///root/PocketMine-MP.phar/src/pocketmine/plugin/MethodEventExecutor.php on line 36 and defined on EH\Main
    This error showed when a player with c-mode killed someone...
  2. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    PHP:
    public function onHurtCMode(EntityDamageEvent $event){
          
    $cause $event->getEntity()->getLastDamageCause();
          if(
    $cause instanceof EntityDamageByEntityEvent){
          
    $hurter $event->getDamager();
          if(
    $hurter->getGamemode() == 1){
            
    $event->setCancelled(true);
            
    $hurter->sendMessage(TextFormat::RED "No creative mode killing please!");
        }
    }
    }
    Legoboy0215 likes this.
  3. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Thanks!!!

Share This Page

Advertisement