multiindicators: fix npe

This commit is contained in:
Ganom
2019-08-30 21:52:03 -04:00
parent 8e18bb6208
commit 673e70d88c

View File

@@ -31,13 +31,12 @@ import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.geom.GeneralPath;
import javax.inject.Inject;
import javax.inject.Singleton;
import net.runelite.api.geometry.Geometry;
import net.runelite.api.Client;
import net.runelite.api.Perspective;
import net.runelite.api.Point;
import net.runelite.api.coords.LocalPoint;
import net.runelite.api.geometry.Geometry;
import net.runelite.api.widgets.Widget;
import net.runelite.api.widgets.WidgetInfo;
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)
{
LocalPoint playerLp = client.getLocalPlayer().getLocalLocation();
Rectangle viewArea = new Rectangle(
if (client.getLocalPlayer() == null)
{
return;
}
final LocalPoint playerLp = client.getLocalPlayer().getLocalLocation();
final Rectangle viewArea = new Rectangle(
playerLp.getX() - MAX_LOCAL_DRAW_LENGTH,
playerLp.getY() - MAX_LOCAL_DRAW_LENGTH,
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);
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)
{
coords[0] = point.getX();
@@ -105,21 +109,28 @@ public class MultiIndicatorsMinimapOverlay extends Overlay
return null;
}
Widget w;
final Widget widget;
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
{
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);
GeneralPath multicombatPath = plugin.getMulticombatPathToDisplay()[client.getPlane()];
GeneralPath pvpPath = plugin.getPvpPathToDisplay()[client.getPlane()];
GeneralPath wildernessLevelLinesPath = plugin.getWildernessLevelLinesPathToDisplay()[client.getPlane()];
final GeneralPath multicombatPath = plugin.getMulticombatPathToDisplay()[client.getPlane()];
final GeneralPath pvpPath = plugin.getPvpPathToDisplay()[client.getPlane()];
final GeneralPath wildernessLevelLinesPath = plugin.getWildernessLevelLinesPathToDisplay()[client.getPlane()];
if (plugin.getMulticombatZoneVisibility() != ZoneVisibility.HIDE && multicombatPath != null)
{