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){
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
Sure, replace this line with this one: PHP: $e = new EntityDamageByChildEntityEvent($this->exempt, $this, $player, EntityDamageEvent::CAUSE_PROJECTILE, GunData::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, $player, EntityDamageEvent::CAUSE_PROJECTILE, GunData::getDamage($this->gunType)); I didn't test it, but it should work
THIS CRASH WAS CAUSED BY A PLUGIN BAD PLUGIN: Weapons v1.12.0 Code: [29] } [30] } [31] return parent: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:AMAGES[$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
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;
No you didn't. And the thing I "left out" was what I thought is common sense. Does this: PHP: $e = new EntityDamageByEntityEvent($this, EntityDamageByEntityEvent::CAUSE_ENTITY_ATTACK, GunData::DAMAGES[$this->gunType]); look like this to you? PHP: $e = new EntityDamageByChildEntityEvent($this->exempt, $this, $player, EntityDamageEvent::CAUSE_PROJECTILE, GunData::DAMAGES[$this->gunType]); Btw if you get free development work done for you, I expect at least a little bit of decency.