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,16 +198,13 @@ public class FlinchingPlugin extends Plugin
else
{
FlinchingTarget currentTarget = flinchingTargets.get(hitId);
if (currentTarget != null)
{
if (resetOnHit)
if (currentTarget != null && resetOnHit)
{
currentTarget.TargetHit();
}
}
}
}
}
else if (resetOnHitReceived && actor == client.getLocalPlayer())
{
PlayerHit();
@@ -224,16 +221,13 @@ public class FlinchingPlugin extends Plugin
NPC newTarget = (NPC) interacting;
currentInteractingId = newTarget.getId();
if (newTarget.getHealth() <= 0 || newTarget.isDead())
{
if (flinchingTargets.containsKey(currentInteractingId))
if ((newTarget.getHealth() <= 0 || newTarget.isDead()) && flinchingTargets.containsKey(currentInteractingId))
{
flinchingTargets.remove(currentInteractingId);
currentInteractingId = -1;
}
}
}
}
private void TickTargets()
{

View File

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