Merge pull request #9182 from Nightfirecat/fix-emote-clues-with-null-stash-units

EmoteClue: Add null checks for stashUnit
This commit is contained in:
Tomas Slusny
2019-06-22 12:49:30 +02:00
committed by GitHub

View File

@@ -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,15 +258,19 @@ public class EmoteClue extends ClueScroll implements TextClueScroll, LocationClu
if (itemRequirements.length > 0) if (itemRequirements.length > 0)
{ {
Client client = plugin.getClient(); Client client = plugin.getClient();
client.runScript(ScriptID.WATSON_STASH_UNIT_CHECK, stashUnit.getObjectId(), 0, 0, 0);
int[] intStack = client.getIntStack();
boolean stashUnitBuilt = intStack[0] == 1;
panelComponent.getChildren().add(LineComponent.builder() if (stashUnit != null)
.left("STASH Unit:") {
.right(stashUnitBuilt ? UNICODE_CHECK_MARK : UNICODE_BALLOT_X) client.runScript(ScriptID.WATSON_STASH_UNIT_CHECK, stashUnit.getObjectId(), 0, 0, 0);
.rightColor(stashUnitBuilt ? Color.GREEN : Color.RED) int[] intStack = client.getIntStack();
.build()); boolean stashUnitBuilt = intStack[0] == 1;
panelComponent.getChildren().add(LineComponent.builder()
.left("STASH Unit:")
.right(stashUnitBuilt ? UNICODE_CHECK_MARK : UNICODE_BALLOT_X)
.rightColor(stashUnitBuilt ? Color.GREEN : Color.RED)
.build());
}
panelComponent.getChildren().add(LineComponent.builder().left("Equip:").build()); panelComponent.getChildren().add(LineComponent.builder().left("Equip:").build());
@@ -312,18 +318,21 @@ 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);
} }
final WorldPoint[] worldPoints = stashUnit.getWorldPoints(); if (stashUnit != null)
for (final WorldPoint worldPoint : worldPoints)
{ {
final LocalPoint stashUnitLocalPoint = LocalPoint.fromWorld(plugin.getClient(), worldPoint); final WorldPoint[] worldPoints = stashUnit.getWorldPoints();
if (stashUnitLocalPoint != null) for (final WorldPoint worldPoint : worldPoints)
{ {
final Polygon poly = Perspective.getCanvasTilePoly(plugin.getClient(), stashUnitLocalPoint); final LocalPoint stashUnitLocalPoint = LocalPoint.fromWorld(plugin.getClient(), worldPoint);
if (poly != null)
if (stashUnitLocalPoint != null)
{ {
OverlayUtil.renderPolygon(graphics, poly, Color.RED); final Polygon poly = Perspective.getCanvasTilePoly(plugin.getClient(), stashUnitLocalPoint);
if (poly != null)
{
OverlayUtil.renderPolygon(graphics, poly, Color.RED);
}
} }
} }
} }