mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 18:32:55 +00:00
Replace disallowed operators in src/entity/
This commit is contained in:
@ -77,7 +77,7 @@ class EffectInstance{
|
||||
* @return $this
|
||||
*/
|
||||
public function setDuration(int $duration) : EffectInstance{
|
||||
if($duration < 0 or $duration > Limits::INT32_MAX){
|
||||
if($duration < 0 || $duration > Limits::INT32_MAX){
|
||||
throw new \InvalidArgumentException("Effect duration must be in range 0 - " . Limits::INT32_MAX . ", got $duration");
|
||||
}
|
||||
$this->duration = $duration;
|
||||
@ -118,7 +118,7 @@ class EffectInstance{
|
||||
* @return $this
|
||||
*/
|
||||
public function setAmplifier(int $amplifier) : EffectInstance{
|
||||
if($amplifier < 0 or $amplifier > 255){
|
||||
if($amplifier < 0 || $amplifier > 255){
|
||||
throw new \InvalidArgumentException("Amplifier must be in range 0 - 255, got $amplifier");
|
||||
}
|
||||
$this->amplifier = $amplifier;
|
||||
|
@ -91,7 +91,7 @@ class EffectManager{
|
||||
$ev = new EntityEffectRemoveEvent($this->entity, $effect);
|
||||
$ev->call();
|
||||
if($ev->isCancelled()){
|
||||
if($hasExpired and !$ev->getEffect()->hasExpired()){ //altered duration of an expired effect to make it not get removed
|
||||
if($hasExpired && !$ev->getEffect()->hasExpired()){ //altered duration of an expired effect to make it not get removed
|
||||
foreach($this->effectAddHooks as $hook){
|
||||
$hook($ev->getEffect(), true);
|
||||
}
|
||||
@ -140,7 +140,7 @@ class EffectManager{
|
||||
$oldEffect = $this->effects[$index];
|
||||
if(
|
||||
abs($effect->getAmplifier()) < $oldEffect->getAmplifier()
|
||||
or (abs($effect->getAmplifier()) === abs($oldEffect->getAmplifier()) and $effect->getDuration() < $oldEffect->getDuration())
|
||||
|| (abs($effect->getAmplifier()) === abs($oldEffect->getAmplifier()) && $effect->getDuration() < $oldEffect->getDuration())
|
||||
){
|
||||
$cancelled = true;
|
||||
}
|
||||
@ -180,7 +180,7 @@ class EffectManager{
|
||||
$colors = [];
|
||||
$ambient = true;
|
||||
foreach($this->effects as $effect){
|
||||
if($effect->isVisible() and $effect->getType()->hasBubbles()){
|
||||
if($effect->isVisible() && $effect->getType()->hasBubbles()){
|
||||
$level = $effect->getEffectLevel();
|
||||
$color = $effect->getColor();
|
||||
for($i = 0; $i < $level; ++$i){
|
||||
|
@ -47,7 +47,7 @@ class PoisonEffect extends Effect{
|
||||
}
|
||||
|
||||
public function applyEffect(Living $entity, EffectInstance $instance, float $potency = 1.0, ?Entity $source = null) : void{
|
||||
if($entity->getHealth() > 1 or $this->fatal){
|
||||
if($entity->getHealth() > 1 || $this->fatal){
|
||||
$ev = new EntityDamageEvent($entity, EntityDamageEvent::CAUSE_MAGIC, 1);
|
||||
$entity->attack($ev);
|
||||
}
|
||||
|
Reference in New Issue
Block a user