Makes sure to only update quest markers if necessary
This commit is contained in:
parent
61fc07f58d
commit
5cd3eac7ff
@ -15,6 +15,7 @@ import org.bukkit.World;
|
|||||||
import org.dynmap.DynmapAPI;
|
import org.dynmap.DynmapAPI;
|
||||||
import org.dynmap.markers.CircleMarker;
|
import org.dynmap.markers.CircleMarker;
|
||||||
import org.dynmap.markers.GenericMarker;
|
import org.dynmap.markers.GenericMarker;
|
||||||
|
import org.dynmap.markers.Marker;
|
||||||
import org.dynmap.markers.MarkerIcon;
|
import org.dynmap.markers.MarkerIcon;
|
||||||
import org.dynmap.markers.MarkerSet;
|
import org.dynmap.markers.MarkerSet;
|
||||||
|
|
||||||
@ -50,6 +51,8 @@ public class QuestsHandler extends AbstractTraitHandler {
|
|||||||
questMarkerSet.setLayerPriority(3);
|
questMarkerSet.setLayerPriority(3);
|
||||||
questAreaMarkerSet.setLayerPriority(2);
|
questAreaMarkerSet.setLayerPriority(2);
|
||||||
isEnabled = true;
|
isEnabled = true;
|
||||||
|
//Remove old quest markers
|
||||||
|
questMarkerSet.getMarkers().forEach(GenericMarker::deleteMarker);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -62,15 +65,19 @@ public class QuestsHandler extends AbstractTraitHandler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Remove old quest markers
|
|
||||||
questMarkerSet.getMarkers().forEach(GenericMarker::deleteMarker);
|
|
||||||
|
|
||||||
//Update all area markers for quests
|
//Update all area markers for quests
|
||||||
updateQuestAreas();
|
updateQuestAreas();
|
||||||
|
|
||||||
//Generate information about all NPCs involved in quests
|
//Generate information about all NPCs involved in quests
|
||||||
generateQuestNPCInfo();
|
generateQuestNPCInfo();
|
||||||
|
|
||||||
|
//Remove any markers for deleted quests
|
||||||
|
for (Marker marker : questMarkerSet.getMarkers()) {
|
||||||
|
if (!questGiverInfo.containsKey(UUID.fromString(marker.getMarkerID()))) {
|
||||||
|
marker.deleteMarker();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//Generate markers based on the generated info
|
//Generate markers based on the generated info
|
||||||
generateAllMarkers();
|
generateAllMarkers();
|
||||||
}
|
}
|
||||||
@ -129,7 +136,15 @@ public class QuestsHandler extends AbstractTraitHandler {
|
|||||||
|
|
||||||
markerDescription.append(getInvolvedInQuestsString(info));
|
markerDescription.append(getInvolvedInQuestsString(info));
|
||||||
|
|
||||||
addNPCMarker(npcId, QuestsHelper.getMarkerTitle(info.getQuestNPCType()), markerDescription.toString(), icon, questMarkerSet);
|
Marker existingMarker = questMarkerSet.findMarker(npcId.toString());
|
||||||
|
String newDescription = markerDescription.toString();
|
||||||
|
if (existingMarker != null) {
|
||||||
|
if (!existingMarker.getDescription().equals(newDescription)) {
|
||||||
|
existingMarker.setDescription(newDescription);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
addNPCMarker(npcId, QuestsHelper.getMarkerTitle(info.getQuestNPCType()), newDescription, icon, questMarkerSet);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user