Closed TrinitroToluen0 closed 6 months ago
Zuri dev 9 I think it happens when using healing splash potions
It seems like the absolute value is returning is 0. I will test later..
It seems like the absolute value is returning is 0. I will test later..
Yeah, this is line 82:
$healRate = (double) $healCount / (double) $healTime;
and, in the definition of $healtime
you are giving a fallback value of 0
that may cause the DivitionByZeroError
$healTime = $playerAPI->getExternalData("healTimeB") ?? 0;
but in most cases the fallback value should not apply so the causes of $healTime being 0 are unknown for me
$healRate = (double) $healCount / (double) $healTime;
$healTime = $playerAPI->getExternalData("healTimeB") ?? 0;
As a result, the first regen should only consider heal rate when the heal time is greater than zero. So, this happens when the heal time has a first run of check, which is the defined null value of 0, resulting in a crash due to division by zero.
Fixed now in #31
DivisionByZeroError: "Division by zero" (EXCEPTION) in "plugins/Zuri_dev-9.phar/src/checks/badpackets/regen/RegenB" at line 82 --- Stack trace ---
0 plugins/Zuri_dev-9.phar/src/listener/PlayerListener(519): ReinfyTeam\Zuri\checks\badpackets\regen\RegenB->checkEvent(object pocketmine\event\entity\EntityRegainHealthEvent#245403, object ReinfyTeam\Zuri\player\PlayerAPI#46511)
1 plugins/Zuri_dev-9.phar/src/listener/PlayerListener(445): ReinfyTeam\Zuri\listener\PlayerListener->checkEvent(object pocketmine\event\entity\EntityRegainHealthEvent#245403, object pocketmine\player\Player#249143)
2 pmsrc/src/event/RegisteredListener(61): ReinfyTeam\Zuri\listener\PlayerListener->onPlayerRegen(object pocketmine\event\entity\EntityRegainHealthEvent#245403)
3 pmsrc/src/event/Event(63): pocketmine\event\RegisteredListener->callEvent(object pocketmine\event\entity\EntityRegainHealthEvent#245403)
4 pmsrc/src/entity/Entity(549): pocketmine\event\Event->call()
5 pmsrc/src/entity/effect/InstantHealthEffect(34): pocketmine\entity\Entity->heal(object pocketmine\event\entity\EntityRegainHealthEvent#245403)
6 pmsrc/src/entity/projectile/SplashPotion(124): pocketmine\entity\effect\InstantHealthEffect->applyEffect(object pocketmine\player\Player#249143, object pocketmine\entity\effect\EffectInstance#213109, float 0.87210889604937, object pocketmine\entity\projectile\SplashPotion#359701)
7 pmsrc/src/entity/projectile/Projectile(237): pocketmine\entity\projectile\SplashPotion->onHit(object pocketmine\event\entity\ProjectileHitBlockEvent#350720)
8 pmsrc/src/entity/Entity(1005): pocketmine\entity\projectile\Projectile->move(float -1.4554866138819, float -0.36905420026223, float 0.19697455205702)
9 pmsrc/src/world/World(997): pocketmine\entity\Entity->onUpdate(int 1105933)
10 pmsrc/src/world/World(922): pocketmine\world\World->actuallyDoTick(int 1105933)
11 pmsrc/src/world/WorldManager(347): pocketmine\world\World->doTick(int 1105933)
12 pmsrc/src/Server(1811): pocketmine\world\WorldManager->tick(int 1105933)
13 pmsrc/src/Server(1693): pocketmine\Server->tick()
14 pmsrc/src/Server(1066): pocketmine\Server->tickProcessor()
15 pmsrc/src/PocketMine(355): pocketmine\Server->__construct(object pocketmine\thread\ThreadSafeClassLoader#6, object pocketmine\utils\MainLogger#2, string[18] /home/admin/Server/, string[26] /home/admin/Server/plugins/)
16 pmsrc/src/PocketMine(378): pocketmine\server()
17 /home/admin/Server/PocketMine-MP.phar(168): require(string[72] phar:///tmp/PocketMine-MP-phar-cache.0/PMMPRsq6rN.tar/src/PocketMine.php)
--- End of exception information ---