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

Killed by Explosive.

Comments in 'Plugin Development' started by xpyctum, May 11, 2015.

  1. xpyctum
    Offline

    xpyctum Active Member Plugin Developer

    Joined:
    Jan 13, 2014
    Posts:
    292
    Plugins:
    4
    Minecraft User:
    tylerdisney
    Hi, help me please with this code.
    PHP:
    public function onDeathEntity(EntityDeathEvent $event){
          
    $entity $event->getEntity();
         
    $cause $entity->getLastDamageCause();
         switch(
    $cause === null ?EntityDamageEvent::CAUSE_CUSTOM $cause->getCause()){
            case 
    EntityDamageEvent::CAUSE_BLOCK_EXPLOSION:
            case 
    EntityDamageEvent::CAUSE_ENTITY_EXPLOSION:
                
    $this->getLogger()->notice("Explosived entity:".$event->getEntity()->getName()); //didn't work, but killed by explosion
            
    break;
         }
    }
  2. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    What's the prob?
  3. xpyctum
    Offline

    xpyctum Active Member Plugin Developer

    Joined:
    Jan 13, 2014
    Posts:
    292
    Plugins:
    4
    Minecraft User:
    tylerdisney
    read commented line.
    PHP:
    $this->getLogger()->notice("Explosived entity:".$event->getEntity()->getName()); //didn't work, but killed by explosion
    PEMapModder likes this.
  4. Samueljh1
    Offline

    Samueljh1 Active Member Plugin Developer

    Joined:
    Jan 9, 2015
    Posts:
    316
    Plugins:
    5
    Minecraft User:
    Samueljh1_
    On my skywars server I use an entitydamagebyentity event. It checks if the damage is fatal, and if it's an instance of TNT.
  5. aliuly
    Offline

    aliuly Notable Member Plugin Developer

    Joined:
    Feb 8, 2014
    Posts:
    1,086
    Plugins:
    17
    There are two death events: PlayerDeathEvent and EntityDeathEvent. I only see one or the other one being triggered (but never both).
    LDX likes this.

Share This Page

Advertisement