babyhydra: Merge nested is statements

This commit is contained in:
sdburns1998
2019-07-07 14:31:34 +02:00
parent 289224785c
commit 00de080ac2
4 changed files with 83 additions and 104 deletions

View File

@@ -53,9 +53,7 @@ public class BabyHydraIndicatorOverlay extends Overlay
@Override @Override
public Dimension render(Graphics2D graphics) public Dimension render(Graphics2D graphics)
{ {
if (plugin.getHydra() != null) if (plugin.getHydra() != null && plugin.getHydras().containsKey(plugin.getHydra().getIndex()))
{
if (plugin.getHydras().containsKey(plugin.getHydra().getIndex()))
{ {
int val = plugin.getHydras().get(plugin.getHydra().getIndex()); int val = plugin.getHydras().get(plugin.getHydra().getIndex());
if (val != 0) if (val != 0)
@@ -65,7 +63,6 @@ public class BabyHydraIndicatorOverlay extends Overlay
return panelComponent.render(graphics); return panelComponent.render(graphics);
} }
} }
}
return null; return null;
} }
} }

View File

@@ -65,9 +65,7 @@ public class BabyHydraOverlay extends Overlay
{ {
continue; continue;
} }
if (hydra.getName().equalsIgnoreCase("Hydra")) if (hydra.getName().equalsIgnoreCase("Hydra") && plugin.getHydras().containsKey(hydra.getIndex()))
{
if (plugin.getHydras().containsKey(hydra.getIndex()))
{ {
int val = plugin.getHydras().get(hydra.getIndex()); int val = plugin.getHydras().get(hydra.getIndex());
if (val != 0) if (val != 0)
@@ -112,7 +110,6 @@ public class BabyHydraOverlay extends Overlay
} }
} }
} }
}
} }
graphics.setFont(FontManager.getRunescapeFont()); graphics.setFont(FontManager.getRunescapeFont());

View File

@@ -159,31 +159,22 @@ public class BabyHydraPlugin extends Plugin
public void onNpcSpawned(NpcSpawned event) public void onNpcSpawned(NpcSpawned event)
{ {
NPC hydra = event.getNpc(); NPC hydra = event.getNpc();
if (hydra.getCombatLevel() != 0 && hydra.getName() != null) if (hydra.getCombatLevel() != 0 && hydra.getName() != null && hydra.getName().equalsIgnoreCase("Hydra") && !hydras.containsKey(hydra.getIndex()))
{
if (hydra.getName().equalsIgnoreCase("Hydra"))
{
if (!hydras.containsKey(hydra.getIndex()))
{ {
hydras.put(hydra.getIndex(), 3); hydras.put(hydra.getIndex(), 3);
} }
} }
}
}
@Subscribe @Subscribe
public void onNpcDespawned(NpcDespawned event) public void onNpcDespawned(NpcDespawned event)
{ {
NPC hydra = event.getNpc(); NPC hydra = event.getNpc();
if (hydra.getCombatLevel() != 0 && hydra.getName() != null) if (hydra.getCombatLevel() != 0 && hydra.getName() != null && hydra.getName().equalsIgnoreCase("Hydra"))
{
if (hydra.getName().equalsIgnoreCase("Hydra"))
{ {
hydras.remove(hydra.getIndex()); hydras.remove(hydra.getIndex());
hydraattacks.remove(hydra.getIndex()); hydraattacks.remove(hydra.getIndex());
} }
} }
}
@Subscribe @Subscribe
public void onAnimationChanged(AnimationChanged event) public void onAnimationChanged(AnimationChanged event)

View File

@@ -78,14 +78,10 @@ public class BabyHydraPrayOverlay extends Overlay
PRAY_RANGED = spriteManager.getSprite(SpriteID.PRAYER_PROTECT_FROM_MISSILES, 0); PRAY_RANGED = spriteManager.getSprite(SpriteID.PRAYER_PROTECT_FROM_MISSILES, 0);
} }
if (plugin.getHydra() != null) if (plugin.getHydra() != null && plugin.getHydras().containsKey(plugin.getHydra().getIndex()))
{
if (plugin.getHydras().containsKey(plugin.getHydra().getIndex()))
{ {
int val = plugin.getHydras().get(plugin.getHydra().getIndex()); int val = plugin.getHydras().get(plugin.getHydra().getIndex());
if (val != 0) if (val != 0 && plugin.getHydraattacks().containsKey(plugin.getHydra().getIndex()))
{
if (plugin.getHydraattacks().containsKey(plugin.getHydra().getIndex()))
{ {
int attack = plugin.getHydraattacks().get(plugin.getHydra().getIndex()); int attack = plugin.getHydraattacks().get(plugin.getHydra().getIndex());
if (attack == 8261) if (attack == 8261)
@@ -136,8 +132,6 @@ public class BabyHydraPrayOverlay extends Overlay
} }
} }
} }
}
}
return null; return null;
} }
} }