Merge pull request #1171 from runelite-extended/groundmarkers

Fix Ground Marker
This commit is contained in:
Tyler Bochard
2019-07-28 17:42:49 -04:00
committed by GitHub

View File

@@ -300,38 +300,38 @@ public class GroundMarkerPlugin extends Plugin
if (hotKeyPressed && event.getOption().equals(WALK_HERE)) if (hotKeyPressed && event.getOption().equals(WALK_HERE))
{ {
MenuEntry[] menuEntries = client.getMenuEntries(); MenuEntry[] menuEntries = client.getMenuEntries();
int lastIndex = menuEntries.length; int lastIndex = menuEntries.length;
menuEntries = Arrays.copyOf(menuEntries, lastIndex + 4); menuEntries = Arrays.copyOf(menuEntries, lastIndex + 4);
final Tile tile = client.getSelectedSceneTile(); final Tile tile = client.getSelectedSceneTile();
if (tile == null) if (tile == null)
{ {
return; return;
} }
final WorldPoint loc = WorldPoint.fromLocalInstance(client, tile.getLocalLocation()); final WorldPoint loc = WorldPoint.fromLocalInstance(client, tile.getLocalLocation());
final int regionId = loc.getRegionID(); final int regionId = loc.getRegionID();
for (int i = 4; i > 0; i--) for (int i = 4; i > 0; i--)
{ {
MenuEntry menuEntry = menuEntries[lastIndex] = new MenuEntry(); MenuEntry menuEntry = menuEntries[lastIndex] = new MenuEntry();
final GroundMarkerPoint point = new GroundMarkerPoint(regionId, loc.getRegionX(), loc.getRegionY(), client.getPlane(), i); final GroundMarkerPoint point = new GroundMarkerPoint(regionId, loc.getRegionX(), loc.getRegionY(), client.getPlane(), i);
final Optional<GroundMarkerPoint> stream = getPoints(regionId).stream().filter(x -> x.equals(point)).findAny(); final Optional<GroundMarkerPoint> stream = getPoints(regionId).stream().filter(x -> x.equals(point)).findAny();
final String option = (stream.isPresent() && stream.get().getGroup() == i) ? UNMARK : MARK; final String option = (stream.isPresent() && stream.get().getGroup() == i) ? UNMARK : MARK;
menuEntry.setOption(ColorUtil.prependColorTag(Text.removeTags(option + (i == 1 ? "" : " (Group " + i + ")")), getColor(i))); menuEntry.setOption(ColorUtil.prependColorTag(Text.removeTags(option + (i == 1 ? "" : " (Group " + i + ")")), getColor(i)));
menuEntry.setTarget(event.getTarget()); menuEntry.setTarget(event.getTarget());
menuEntry.setType(MenuAction.RUNELITE.getId()); menuEntry.setType(MenuAction.RUNELITE.getId());
lastIndex++;
}
lastIndex++;
}
client.setMenuEntries(menuEntries); client.setMenuEntries(menuEntries);
} }
} }
private void onMenuOptionClicked(MenuOptionClicked event) private void onMenuOptionClicked(MenuOptionClicked event)
{ {
if (event.getMenuAction().getId() != MenuAction.RUNELITE.getId() || if (!event.getOption().contains(MARK) && !event.getOption().contains(UNMARK))
!(event.getOption().equals(MARK) || event.getOption().equals(UNMARK)))
{ {
return; return;
} }