object indicators: fix unmarking objects matched by name

This commit is contained in:
Adam
2019-12-02 19:43:11 -05:00
parent d6198ff311
commit 883fd21cfd

View File

@@ -309,7 +309,7 @@ public class ObjectIndicatorsPlugin extends Plugin implements KeyListener
return;
}
markObject(name, object);
markObject(objectDefinition, name, object);
}
private void checkObjectPoints(TileObject object)
@@ -406,13 +406,14 @@ public class ObjectIndicatorsPlugin extends Plugin implements KeyListener
return false;
}
private void markObject(String name, final TileObject object)
/** mark or unmark an object
*
* @param objectComposition transformed composition of object based on vars
* @param name name of objectComposition
* @param object tile object, for multilocs object.getId() is the base id
*/
private void markObject(ObjectComposition objectComposition, String name, final TileObject object)
{
if (object == null)
{
return;
}
final WorldPoint worldPoint = WorldPoint.fromLocalInstance(client, object.getLocalLocation());
final int regionId = worldPoint.getRegionID();
final ObjectPoint point = new ObjectPoint(
@@ -427,9 +428,11 @@ public class ObjectIndicatorsPlugin extends Plugin implements KeyListener
if (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())
// Find the object point that caused this object to be marked, there are two cases:
// 1) object is a multiloc, the name may have changed since marking - match from base id
// 2) not a multiloc, but an object has spawned with an identical name and a different
// id as what was originally marked
if (!objectPoints.removeIf(op -> ((op.getId() == -1 || op.getId() == object.getId()) || op.getName().equals(objectComposition.getName()))
&& op.getRegionX() == worldPoint.getRegionX()
&& op.getRegionY() == worldPoint.getRegionY()
&& op.getZ() == worldPoint.getPlane()))