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

View File

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