1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

EntityDamageByBlockEvent

Discussion in 'Plugin Help' started by GooseBumps98, Mar 6, 2020.

  1. GooseBumps98

    GooseBumps98 Spider

    Messages:
    13
    Does anybody know what code I need to add so it doesnt crash when shot with a weapon https://poggit.pmmp.io/p/Weapons/1.12.0 <=== Weapon plugin

    The server crashes when a player dies from being killed by a weapon ( via Weapon Plugin )

    Code:
    THIS CRASH WAS CAUSED BY A PLUGIN
    BAD PLUGIN: CustomAlerts v2.1
    
    Code:
    [450]                     $message = $this->cfg["Death"]["death-contact-message"]["message"];
    [451]                     if($cause instanceof EntityDamageByBlockEvent){
    [452]                         $array["BLOCK"] = $cause->getDamager()->getName();
    [453]                         break;
    [454]                     }
    [455]                     $array["BLOCK"] = "Unknown";
    [456]                     break;
    [457]                 case EntityDamageEvent::CAUSE_ENTITY_ATTACK:
    [458]                     $message = $this->cfg["Death"]["kill-message"]["message"];
    [459]                     $killer = $cause->getDamager();
    [460]                     if($killer instanceof Living){
    [461]                         $array["KILLER"] = $killer->getName();
    [462]                         break;
    [463]                     }
    [464]                     $array["KILLER"] = "Unknown";
    [465]                     break;
    [466]                 case EntityDamageEvent::CAUSE_PROJECTILE:
    [467]                     $message = $this->cfg["Death"]["death-projectile-message"]["message"];
    [468]                     $killer = $cause->getDamager();
    [469]                     if($killer instanceof Living){
     
    Last edited: Mar 6, 2020
  2. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    Can you send us the actual error message and where you got that CustomAlerts plugin from?
     
  3. GooseBumps98

    GooseBumps98 Spider

    Messages:
    13
    GamakCZ likes this.
  4. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    This is because CustomAlerts forgot to check whether the event was an EntityDamageByEntityEvent and because the Weapons plugin used EntityDamageEvent instead of EntityDamageByEntityEvent. If either of these isssues would be fixed, the crash wouldn't happen.
    You can report this to any (or both) developers of those plugins and hope they fix it or ask someone else to patch the plugin(s) for you
     
    GamakCZ likes this.
  5. GooseBumps98

    GooseBumps98 Spider

    Messages:
    13
    Can you tell me what to change and where ... cant Wait for the devs
     
  6. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    Sure, replace this line with this one:
    PHP:
    $e = new EntityDamageByChildEntityEvent($this->exempt$this$playerEntityDamageEvent::CAUSE_PROJECTILEGunData::DAMAGES[$this->gunType]);
    or with this one if you use the master branch of the plugin instead of the release version.
    PHP:
    $e = new EntityDamageByChildEntityEvent($this->exempt$this$playerEntityDamageEvent::CAUSE_PROJECTILEGunData::getDamage($this->gunType));
    I didn't test it, but it should work
     
    Last edited: Mar 9, 2020
  7. GooseBumps98

    GooseBumps98 Spider

    Messages:
    13
    You posted the same thing
     
  8. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    No I didn't
     
  9. GooseBumps98

    GooseBumps98 Spider

    Messages:
    13
    THIS CRASH WAS CAUSED BY A PLUGIN
    BAD PLUGIN: Weapons v1.12.0

    Code:
    [29] }
    [30] }
    [31] return parent::eek:nUpdate($currentTick);
    [32] }
    [33]
    [34] public function onCollideWithPlayer(Player $player): void{
    [35] if(!$this->onGround){
    [36] if($player === $this->exempt) return;
    [37]
    [38] $e = new EntityDamageByEntityEvent($this, EntityDamageByEntityEvent::CAUSE_ENTITY_ATTACK, GunData::DAMAGES[$this->gunType]);
    [39] $e->setAttackCooldown(0);
    [40] $player->attack($e);
    [41]
    [42] if(isset(GunData::EXPLODE[$this->gunType])){
    [43] $rad = GunData::EXPLODE[$this->gunType];
    [44]
    [45] $explode = new Explosion($this, $rad);
    [46] $explode->explodeB();
    [47] }
    [48]

    Backtrace:
    #0 src/pocketmine/Player(1510): xBeastMode\Weapons\BulletEntity->onCollideWithPlayer(object pocketmine\Player)
    #1 src/pocketmine/Player(1715): pocketmine\Player->checkNearEntities()
    #2 src/pocketmine/level/Level(844): pocketmine\Player->onUpdate(integer 7608)
    #3 src/pocketmine/level/Level(777): pocketmine\level\Level->actuallyDoTick(integer 7608)
    #4 src/pocketmine/Server(2256): pocketmine\level\Level->doTick(integer 7608)
    #5 src/pocketmine/Server(2387): pocketmine\Server->checkTickUpdates(integer 7608, double 1583650483.653)
    #6 src/pocketmine/Server(2143): pocketmine\Server->tick()
    #7 src/pocketmine/Server(1990): pocketmine\Server->tickProcessor()
    #8 src/pocketmine/Server(1584): pocketmine\Server->start()
    #9 src/pocketmine/PocketMine(273): pocketmine\Server->__construct(object BaseClassLoader, object pocketmine\utils\MainLogger, string[13] /root/server/, string[21] /root/server/plugins/)
    #10 src/pocketmine/PocketMine(296): pocketmine\server()
    #11 (11): require(string[68] phar:///root/server/PocketMine-MP.phar/src/pocketmine/PocketMine.php)

    PocketMine-MP version: 3.11.6 [Protocol 389]
    Git commit: cb9e79b3985719671bd5cbaa7f665b04a6d33359-dirty
    uname -a: Linux Bumpe 4.15.0-66-generic #75-Ubuntu SMP Tue Oct 1 05:24:09 UTC 2019 x86_64
    PHP Version: 7.3.14
    Zend version: 3.3.14
    OS : Linux, linux
     
  10. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    Copy my code EXACTLY like I wrote it!
    Also I forgot, you need to add this to the other use statements:
    PHP:
    use pocketmine\event\entity\EntityDamageEvent;
     
  11. GooseBumps98

    GooseBumps98 Spider

    Messages:
    13
    I wrote it how you wrote it , you left out that one part so dont put EXACTLY
     
  12. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    No you didn't. And the thing I "left out" was what I thought is common sense.

    Does this:
    PHP:
    $e = new EntityDamageByEntityEvent($thisEntityDamageByEntityEvent::CAUSE_ENTITY_ATTACKGunData::DAMAGES[$this->gunType]);
    look like this to you?
    PHP:
    $e = new EntityDamageByChildEntityEvent($this->exempt$this$playerEntityDamageEvent::CAUSE_PROJECTILEGunData::DAMAGES[$this->gunType]);
    Btw if you get free development work done for you, I expect at least a little bit of decency.
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.