zulrah: Fix NPE (#1209)

* zulrah: Fix NPE

* Add nullable tags to phases.
This commit is contained in:
Ganom
2019-07-31 17:23:33 -04:00
committed by Lucwousin
parent 8d2b4a7310
commit bbf6bb8850
2 changed files with 20 additions and 13 deletions

View File

@@ -27,6 +27,7 @@
package net.runelite.client.plugins.zulrah;
import javax.annotation.Nullable;
import net.runelite.api.NPC;
import net.runelite.api.Prayer;
import net.runelite.api.coords.LocalPoint;
@@ -101,6 +102,7 @@ public class ZulrahInstance
stage = 0;
}
@Nullable
public ZulrahPhase getPhase()
{
ZulrahPhase patternPhase = null;
@@ -116,6 +118,7 @@ public class ZulrahInstance
this.phase = phase;
}
@Nullable
public ZulrahPhase getNextPhase()
{
if (pattern != null)

View File

@@ -217,28 +217,32 @@ public class ZulrahPlugin extends Plugin
}
ZulrahPhase currentPhase = instance.getPhase();
ZulrahPhase nextPhase = instance.getNextPhase();
if (currentPhase == null)
if (currentPhase == null || nextPhase == null)
{
return;
}
Actor actor = event.getActor();
final Actor actor = event.getActor();
if (config.sounds() && zulrah != null && zulrah.equals(actor) && zulrah.getAnimation() == AnimationID.ZULRAH_PHASE)
{
Prayer prayer = instance.getNextPhase().getPrayer();
Prayer prayer = nextPhase.getPrayer();
if (prayer != null)
if (prayer == null)
{
switch (prayer)
{
case PROTECT_FROM_MAGIC:
soundManager.playSound(Sound.PRAY_MAGIC);
break;
case PROTECT_FROM_MISSILES:
soundManager.playSound(Sound.PRAY_RANGED);
break;
}
return;
}
switch (prayer)
{
case PROTECT_FROM_MAGIC:
soundManager.playSound(Sound.PRAY_MAGIC);
break;
case PROTECT_FROM_MISSILES:
soundManager.playSound(Sound.PRAY_RANGED);
break;
}
}
}