Skip to content

Commit

Permalink
fix: Store waystone type per waypoint to properly remove later
Browse files Browse the repository at this point in the history
  • Loading branch information
BlayTheNinth committed Jun 24, 2024
1 parent 1f9cba8 commit ce049ea
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class JourneyMapIntegration implements IClientPlugin {
private WaypointGroup sharestonesGroup;
private boolean journeyMapReady;
private final Map<UUID, String> waystoneToWaypoint = new HashMap<>();
private final Map<String, ResourceLocation> waypointTypes = new HashMap<>();

private final List<Runnable> scheduledJobsWhenReady = new ArrayList<>();

Expand Down Expand Up @@ -116,7 +117,6 @@ private void runWhenJourneyMapIsReady(Runnable runnable) {
}

private void updateAllWaypoints(ResourceLocation waystoneType, List<Waystone> waystones) {
final var idPrefix = waystoneType.getPath() + ":";
final var stillExistingIds = new HashSet<String>();
for (final var waystone : waystones) {
stillExistingIds.add(waystone.getWaystoneUid().toString());
Expand All @@ -125,7 +125,8 @@ private void updateAllWaypoints(ResourceLocation waystoneType, List<Waystone> wa

final var waypoints = api.getWaypoints(Waystones.MOD_ID);
for (final var waypoint : waypoints) {
if (waypoint.getId().startsWith(idPrefix) && !stillExistingIds.contains(waypoint.getId())) {
final var type = waypointTypes.get(waypoint.getGuid());
if (waystoneType.equals(type) && !stillExistingIds.contains(waypoint.getId())) {
api.removeWaypoint(Waystones.MOD_ID, waypoint);
}
}
Expand Down Expand Up @@ -158,7 +159,8 @@ private void updateWaypoint(Waystone waystone) {
api.removeWaypoint(Waystones.MOD_ID, oldWaypoint);
}
api.addWaypoint(Waystones.MOD_ID, waypoint);
waystoneToWaypoint.put(waystone.getWaystoneUid(), waypoint.getId());
waystoneToWaypoint.put(waystone.getWaystoneUid(), waypoint.getGuid());
waypointTypes.put(waypoint.getGuid(), waystone.getWaystoneType());

final var group = getWaystoneGroup(waystone);
if (group != null) {
Expand Down

0 comments on commit ce049ea

Please sign in to comment.