ground markers: show existing label when labeling a marker
This commit is contained in:
@@ -34,6 +34,7 @@ import java.util.Arrays;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
@@ -313,21 +314,22 @@ public class GroundMarkerPlugin extends Plugin
|
|||||||
WorldPoint worldPoint = WorldPoint.fromLocalInstance(client, localPoint);
|
WorldPoint worldPoint = WorldPoint.fromLocalInstance(client, localPoint);
|
||||||
final int regionId = worldPoint.getRegionID();
|
final int regionId = worldPoint.getRegionID();
|
||||||
|
|
||||||
|
GroundMarkerPoint searchPoint = new GroundMarkerPoint(regionId, worldPoint.getRegionX(), worldPoint.getRegionY(), client.getPlane(), null, null);
|
||||||
|
Collection<GroundMarkerPoint> points = getPoints(regionId);
|
||||||
|
GroundMarkerPoint existing = points.stream()
|
||||||
|
.filter(p -> p.equals(searchPoint))
|
||||||
|
.findFirst().orElse(null);
|
||||||
|
if (existing == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
chatboxPanelManager.openTextInput("Tile label")
|
chatboxPanelManager.openTextInput("Tile label")
|
||||||
|
.value(Optional.ofNullable(existing.getLabel()).orElse(""))
|
||||||
.onDone((input) ->
|
.onDone((input) ->
|
||||||
{
|
{
|
||||||
input = Strings.emptyToNull(input);
|
input = Strings.emptyToNull(input);
|
||||||
|
|
||||||
GroundMarkerPoint searchPoint = new GroundMarkerPoint(regionId, worldPoint.getRegionX(), worldPoint.getRegionY(), client.getPlane(), null, null);
|
|
||||||
Collection<GroundMarkerPoint> points = getPoints(regionId);
|
|
||||||
GroundMarkerPoint existing = points.stream()
|
|
||||||
.filter(p -> p.equals(searchPoint))
|
|
||||||
.findFirst().orElse(null);
|
|
||||||
if (existing == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
GroundMarkerPoint newPoint = new GroundMarkerPoint(regionId, worldPoint.getRegionX(), worldPoint.getRegionY(), client.getPlane(), existing.getColor(), input);
|
GroundMarkerPoint newPoint = new GroundMarkerPoint(regionId, worldPoint.getRegionX(), worldPoint.getRegionY(), client.getPlane(), existing.getColor(), input);
|
||||||
points.remove(searchPoint);
|
points.remove(searchPoint);
|
||||||
points.add(newPoint);
|
points.add(newPoint);
|
||||||
|
|||||||
Reference in New Issue
Block a user