object markers: fix removing markers from multilocs

multilocs whose name changed would not be matched if unmarked after the
name change due to the name mismatch, use object id instead.
This commit is contained in:
Adam
2019-11-20 21:31:54 -05:00
parent 8528ba72c6
commit 2c5f52e57c
2 changed files with 19 additions and 5 deletions

View File

@@ -416,6 +416,7 @@ public class ObjectIndicatorsPlugin extends Plugin implements KeyListener
final WorldPoint worldPoint = WorldPoint.fromLocalInstance(client, object.getLocalLocation());
final int regionId = worldPoint.getRegionID();
final ObjectPoint point = new ObjectPoint(
object.getId(),
name,
regionId,
worldPoint.getRegionX(),
@@ -424,10 +425,18 @@ public class ObjectIndicatorsPlugin extends Plugin implements KeyListener
Set<ObjectPoint> objectPoints = points.computeIfAbsent(regionId, k -> new HashSet<>());
if (objectPoints.contains(point))
if (objects.remove(object))
{
objectPoints.remove(point);
objects.remove(object);
// Use object id instead of name to match the object point with this object due to the object name being
// able to change because of multilocs.
if (!objectPoints.removeIf(op -> (op.getId() == -1 || op.getId() == object.getId())
&& op.getRegionX() == worldPoint.getRegionX()
&& op.getRegionY() == worldPoint.getRegionY()
&& op.getZ() == worldPoint.getPlane()))
{
log.warn("unable to find object point for unmarked object {}", object.getId());
}
log.debug("Unmarking object: {}", point);
}
else

View File

@@ -25,11 +25,16 @@
package net.runelite.client.plugins.objectindicators;
import lombok.Value;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Value
@Data
@NoArgsConstructor
@AllArgsConstructor
class ObjectPoint
{
private int id = -1;
private String name;
private int regionId;
private int regionX;