flinchingplugin: Merge nested if statements

This commit is contained in:
sdburns1998
2019-07-07 04:12:49 +02:00
parent 9a87f7b7be
commit 5a1a0e215b
2 changed files with 7 additions and 16 deletions

View File

@@ -198,12 +198,9 @@ public class FlinchingPlugin extends Plugin
else
{
FlinchingTarget currentTarget = flinchingTargets.get(hitId);
if (currentTarget != null)
if (currentTarget != null && resetOnHit)
{
if (resetOnHit)
{
currentTarget.TargetHit();
}
currentTarget.TargetHit();
}
}
}
@@ -224,13 +221,10 @@ public class FlinchingPlugin extends Plugin
NPC newTarget = (NPC) interacting;
currentInteractingId = newTarget.getId();
if (newTarget.getHealth() <= 0 || newTarget.isDead())
if ((newTarget.getHealth() <= 0 || newTarget.isDead()) && flinchingTargets.containsKey(currentInteractingId))
{
if (flinchingTargets.containsKey(currentInteractingId))
{
flinchingTargets.remove(currentInteractingId);
currentInteractingId = -1;
}
flinchingTargets.remove(currentInteractingId);
currentInteractingId = -1;
}
}
}

View File

@@ -63,12 +63,9 @@ public class FlinchingTarget
void TargetHit()
{
boolean shouldHit = true;
if (usingHitDelay)
if (usingHitDelay && GetRemainingTime() > displayLength)
{
if (GetRemainingTime() > displayLength)
{
shouldHit = false;
}
shouldHit = false;
}
if (shouldHit)