Fix updating of Hot/Cold clue

- Properly reset the WorldMapPoints when Hot/Cold clue updates.
- Add null-check for location
- Add size check for multiple location points

Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
Tomas Slusny
2018-05-12 13:55:43 +02:00
parent 7d815b7216
commit f66c2ff627
3 changed files with 26 additions and 10 deletions

View File

@@ -190,7 +190,10 @@ public class ClueScrollPlugin extends Plugin
if (clue instanceof LocationsClueScroll) if (clue instanceof LocationsClueScroll)
{ {
((LocationsClueScroll)clue).update(event.getMessage(), this); if (((LocationsClueScroll)clue).update(event.getMessage(), this))
{
worldMapPointsSet = false;
}
} }
if (!event.getMessage().equals("The strange device cools as you find your treasure.") if (!event.getMessage().equals("The strange device cools as you find your treasure.")
@@ -261,7 +264,11 @@ public class ClueScrollPlugin extends Plugin
if (clue instanceof LocationsClueScroll) if (clue instanceof LocationsClueScroll)
{ {
final List<WorldPoint> locations = ((LocationsClueScroll) clue).getLocations(); final List<WorldPoint> locations = ((LocationsClueScroll) clue).getLocations();
addMapPoints(locations.toArray(new WorldPoint[locations.size()]));
if (!locations.isEmpty())
{
addMapPoints(locations.toArray(new WorldPoint[locations.size()]));
}
} }
// If we have location clue, set world location before all other types of clues // If we have location clue, set world location before all other types of clues
@@ -270,12 +277,15 @@ public class ClueScrollPlugin extends Plugin
{ {
final WorldPoint location = ((LocationClueScroll) clue).getLocation(); final WorldPoint location = ((LocationClueScroll) clue).getLocation();
if (config.displayHintArrows() && location != null) if (location != null)
{ {
client.setHintArrow(location); if (config.displayHintArrows())
} {
client.setHintArrow(location);
}
addMapPoints(location); addMapPoints(location);
}
} }
if (clue instanceof NpcClueScroll) if (clue instanceof NpcClueScroll)
@@ -395,7 +405,7 @@ public class ClueScrollPlugin extends Plugin
clueItemChanged = false; clueItemChanged = false;
clue = null; clue = null;
worldMapPointManager.removeIf(point -> point instanceof ClueScrollWorldMapPoint); worldMapPointManager.removeIf(ClueScrollWorldMapPoint.class::isInstance);
worldMapPointsSet = false; worldMapPointsSet = false;
if (config.displayHintArrows()) if (config.displayHintArrows())
@@ -560,6 +570,7 @@ public class ClueScrollPlugin extends Plugin
} }
worldMapPointsSet = true; worldMapPointsSet = true;
worldMapPointManager.removeIf(ClueScrollWorldMapPoint.class::isInstance);
for (final WorldPoint point : points) for (final WorldPoint point : points)
{ {

View File

@@ -248,11 +248,11 @@ public class HotColdClue extends ClueScroll implements LocationClueScroll, Locat
} }
@Override @Override
public void update(final String message, final ClueScrollPlugin plugin) public boolean update(final String message, final ClueScrollPlugin plugin)
{ {
if (!message.startsWith("The device is")) if (!message.startsWith("The device is"))
{ {
return; return false;
} }
Matcher m1 = FINAL_STRANGE_DEVICE_MESSAGE.matcher(message); Matcher m1 = FINAL_STRANGE_DEVICE_MESSAGE.matcher(message);
@@ -268,6 +268,7 @@ public class HotColdClue extends ClueScroll implements LocationClueScroll, Locat
if (localWorld != null) if (localWorld != null)
{ {
markFinalSpot(localWorld); markFinalSpot(localWorld);
return true;
} }
} }
else if (m2.find()) else if (m2.find())
@@ -279,6 +280,7 @@ public class HotColdClue extends ClueScroll implements LocationClueScroll, Locat
if (localWorld != null) if (localWorld != null)
{ {
updatePossibleArea(localWorld, temperature, difference); updatePossibleArea(localWorld, temperature, difference);
return true;
} }
} }
else if (m3.find()) else if (m3.find())
@@ -289,8 +291,11 @@ public class HotColdClue extends ClueScroll implements LocationClueScroll, Locat
if (localWorld != null) if (localWorld != null)
{ {
updatePossibleArea(localWorld, temperature, ""); updatePossibleArea(localWorld, temperature, "");
return true;
} }
} }
return false;
} }
@Override @Override

View File

@@ -30,7 +30,7 @@ import net.runelite.client.plugins.cluescrolls.ClueScrollPlugin;
public interface LocationsClueScroll public interface LocationsClueScroll
{ {
void update(String message, ClueScrollPlugin plugin); boolean update(String message, ClueScrollPlugin plugin);
void reset(); void reset();