ground markers: show existing label when labeling a marker

This commit is contained in:
Hydrox6
2021-02-09 14:25:46 +00:00
committed by Jordan Atwood
parent 2a953b497b
commit 4169bba52d

View File

@@ -34,6 +34,7 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import javax.inject.Inject;
import lombok.AccessLevel;
@@ -313,21 +314,22 @@ public class GroundMarkerPlugin extends Plugin
WorldPoint worldPoint = WorldPoint.fromLocalInstance(client, localPoint);
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")
.value(Optional.ofNullable(existing.getLabel()).orElse(""))
.onDone((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);
points.remove(searchPoint);
points.add(newPoint);