Fix NPE in groundmarker plugin

Right-clicking the void in puro-puro sets the selectedSceneTile to null.
This commit is contained in:
dekvall
2019-08-07 20:25:23 +02:00
parent efc37e00d5
commit 85a5eb0cf9
2 changed files with 9 additions and 2 deletions

View File

@@ -418,6 +418,7 @@ public interface Client extends GameEngine
* *
* @return the selected tile * @return the selected tile
*/ */
@Nullable
Tile getSelectedSceneTile(); Tile getSelectedSceneTile();
/** /**

View File

@@ -209,12 +209,18 @@ public class GroundMarkerPlugin extends Plugin
{ {
if (hotKeyPressed && event.getOption().equals(WALK_HERE)) if (hotKeyPressed && event.getOption().equals(WALK_HERE))
{ {
final Tile selectedSceneTile = client.getSelectedSceneTile();
if (selectedSceneTile == null)
{
return;
}
MenuEntry[] menuEntries = client.getMenuEntries(); MenuEntry[] menuEntries = client.getMenuEntries();
menuEntries = Arrays.copyOf(menuEntries, menuEntries.length + 1); menuEntries = Arrays.copyOf(menuEntries, menuEntries.length + 1);
MenuEntry menuEntry = menuEntries[menuEntries.length - 1] = new MenuEntry(); MenuEntry menuEntry = menuEntries[menuEntries.length - 1] = new MenuEntry();
final WorldPoint worldPoint = WorldPoint.fromLocalInstance(client, client.getSelectedSceneTile().getLocalLocation()); final WorldPoint worldPoint = WorldPoint.fromLocalInstance(client, selectedSceneTile.getLocalLocation());
final int regionId = worldPoint.getRegionID(); final int regionId = worldPoint.getRegionID();
final GroundMarkerPoint point = new GroundMarkerPoint(regionId, worldPoint.getRegionX(), worldPoint.getRegionY(), client.getPlane(), config.markerColor()); final GroundMarkerPoint point = new GroundMarkerPoint(regionId, worldPoint.getRegionX(), worldPoint.getRegionY(), client.getPlane(), config.markerColor());