EmoteClue: Add null checks for stashUnit
Some clues may have item requirements, but no STASH unit, which would cause NPEs during rendering. This commit also marks stashUnit as nullable so this issue can hopefully be avoided in the future.
This commit is contained in:
@@ -30,6 +30,7 @@ import java.awt.Graphics2D;
|
|||||||
import java.awt.Polygon;
|
import java.awt.Polygon;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.api.EquipmentInventorySlot;
|
import net.runelite.api.EquipmentInventorySlot;
|
||||||
@@ -214,6 +215,7 @@ public class EmoteClue extends ClueScroll implements TextClueScroll, LocationClu
|
|||||||
}
|
}
|
||||||
|
|
||||||
private final String text;
|
private final String text;
|
||||||
|
@Nullable
|
||||||
private final STASHUnit stashUnit;
|
private final STASHUnit stashUnit;
|
||||||
private final WorldPoint location;
|
private final WorldPoint location;
|
||||||
private final Emote firstEmote;
|
private final Emote firstEmote;
|
||||||
@@ -256,6 +258,9 @@ public class EmoteClue extends ClueScroll implements TextClueScroll, LocationClu
|
|||||||
if (itemRequirements.length > 0)
|
if (itemRequirements.length > 0)
|
||||||
{
|
{
|
||||||
Client client = plugin.getClient();
|
Client client = plugin.getClient();
|
||||||
|
|
||||||
|
if (stashUnit != null)
|
||||||
|
{
|
||||||
client.runScript(ScriptID.WATSON_STASH_UNIT_CHECK, stashUnit.getObjectId(), 0, 0, 0);
|
client.runScript(ScriptID.WATSON_STASH_UNIT_CHECK, stashUnit.getObjectId(), 0, 0, 0);
|
||||||
int[] intStack = client.getIntStack();
|
int[] intStack = client.getIntStack();
|
||||||
boolean stashUnitBuilt = intStack[0] == 1;
|
boolean stashUnitBuilt = intStack[0] == 1;
|
||||||
@@ -265,6 +270,7 @@ public class EmoteClue extends ClueScroll implements TextClueScroll, LocationClu
|
|||||||
.right(stashUnitBuilt ? UNICODE_CHECK_MARK : UNICODE_BALLOT_X)
|
.right(stashUnitBuilt ? UNICODE_CHECK_MARK : UNICODE_BALLOT_X)
|
||||||
.rightColor(stashUnitBuilt ? Color.GREEN : Color.RED)
|
.rightColor(stashUnitBuilt ? Color.GREEN : Color.RED)
|
||||||
.build());
|
.build());
|
||||||
|
}
|
||||||
|
|
||||||
panelComponent.getChildren().add(LineComponent.builder().left("Equip:").build());
|
panelComponent.getChildren().add(LineComponent.builder().left("Equip:").build());
|
||||||
|
|
||||||
@@ -312,6 +318,8 @@ public class EmoteClue extends ClueScroll implements TextClueScroll, LocationClu
|
|||||||
OverlayUtil.renderTileOverlay(plugin.getClient(), graphics, localPoint, plugin.getEmoteImage(), Color.ORANGE);
|
OverlayUtil.renderTileOverlay(plugin.getClient(), graphics, localPoint, plugin.getEmoteImage(), Color.ORANGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (stashUnit != null)
|
||||||
|
{
|
||||||
final WorldPoint[] worldPoints = stashUnit.getWorldPoints();
|
final WorldPoint[] worldPoints = stashUnit.getWorldPoints();
|
||||||
|
|
||||||
for (final WorldPoint worldPoint : worldPoints)
|
for (final WorldPoint worldPoint : worldPoints)
|
||||||
@@ -328,6 +336,7 @@ public class EmoteClue extends ClueScroll implements TextClueScroll, LocationClu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static EmoteClue forText(String text)
|
public static EmoteClue forText(String text)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user