multiindicators: fix npe (#1493)

multiindicators: fix npe
This commit is contained in:
ST0NEWALL
2019-08-31 05:11:51 -04:00
committed by GitHub

View File

@@ -31,13 +31,12 @@ import java.awt.Graphics2D;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.geom.GeneralPath; import java.awt.geom.GeneralPath;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
import net.runelite.api.geometry.Geometry;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.api.Perspective; import net.runelite.api.Perspective;
import net.runelite.api.Point; import net.runelite.api.Point;
import net.runelite.api.coords.LocalPoint; import net.runelite.api.coords.LocalPoint;
import net.runelite.api.geometry.Geometry;
import net.runelite.api.widgets.Widget; import net.runelite.api.widgets.Widget;
import net.runelite.api.widgets.WidgetInfo; import net.runelite.api.widgets.WidgetInfo;
import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.Overlay;
@@ -71,8 +70,13 @@ public class MultiIndicatorsMinimapOverlay extends Overlay
private void renderPath(Graphics2D graphics, GeneralPath path, Color color) private void renderPath(Graphics2D graphics, GeneralPath path, Color color)
{ {
LocalPoint playerLp = client.getLocalPlayer().getLocalLocation(); if (client.getLocalPlayer() == null)
Rectangle viewArea = new Rectangle( {
return;
}
final LocalPoint playerLp = client.getLocalPlayer().getLocalLocation();
final Rectangle viewArea = new Rectangle(
playerLp.getX() - MAX_LOCAL_DRAW_LENGTH, playerLp.getX() - MAX_LOCAL_DRAW_LENGTH,
playerLp.getY() - MAX_LOCAL_DRAW_LENGTH, playerLp.getY() - MAX_LOCAL_DRAW_LENGTH,
MAX_LOCAL_DRAW_LENGTH * 2, MAX_LOCAL_DRAW_LENGTH * 2,
@@ -86,7 +90,7 @@ public class MultiIndicatorsMinimapOverlay extends Overlay
Perspective.localToMinimap(client, new LocalPoint((int) p2[0], (int) p2[1])) != null); Perspective.localToMinimap(client, new LocalPoint((int) p2[0], (int) p2[1])) != null);
path = Geometry.transformPath(path, coords -> path = Geometry.transformPath(path, coords ->
{ {
Point point = Perspective.localToMinimap(client, new LocalPoint((int) coords[0], (int) coords[1])); final Point point = Perspective.localToMinimap(client, new LocalPoint((int) coords[0], (int) coords[1]));
if (point != null) if (point != null)
{ {
coords[0] = point.getX(); coords[0] = point.getX();
@@ -105,21 +109,28 @@ public class MultiIndicatorsMinimapOverlay extends Overlay
return null; return null;
} }
Widget w; final Widget widget;
if (client.getWidget(WidgetInfo.FIXED_VIEWPORT_MINIMAP_DRAW_AREA) != null) if (client.getWidget(WidgetInfo.FIXED_VIEWPORT_MINIMAP_DRAW_AREA) != null)
{ {
w = client.getWidget(WidgetInfo.FIXED_VIEWPORT_MINIMAP_DRAW_AREA); widget = client.getWidget(WidgetInfo.FIXED_VIEWPORT_MINIMAP_DRAW_AREA);
} }
else else
{ {
w = client.getWidget(WidgetInfo.RESIZABLE_MINIMAP_STONES_DRAW_AREA); widget = client.getWidget(WidgetInfo.RESIZABLE_MINIMAP_STONES_DRAW_AREA);
} }
Rectangle minimapClip = w.getBounds();
if (widget == null)
{
return null;
}
final Rectangle minimapClip = widget.getBounds();
graphics.setClip(minimapClip); graphics.setClip(minimapClip);
GeneralPath multicombatPath = plugin.getMulticombatPathToDisplay()[client.getPlane()]; final GeneralPath multicombatPath = plugin.getMulticombatPathToDisplay()[client.getPlane()];
GeneralPath pvpPath = plugin.getPvpPathToDisplay()[client.getPlane()]; final GeneralPath pvpPath = plugin.getPvpPathToDisplay()[client.getPlane()];
GeneralPath wildernessLevelLinesPath = plugin.getWildernessLevelLinesPathToDisplay()[client.getPlane()]; final GeneralPath wildernessLevelLinesPath = plugin.getWildernessLevelLinesPathToDisplay()[client.getPlane()];
if (plugin.getMulticombatZoneVisibility() != ZoneVisibility.HIDE && multicombatPath != null) if (plugin.getMulticombatZoneVisibility() != ZoneVisibility.HIDE && multicombatPath != null)
{ {