Fix markers not being removed

Markers were saved in a (Hash)Set even though they are mutable. Reducing the
exposed interface to Collection allows changing the interal implementation to
ArrayList which solves the problem.
This commit is contained in:
johni0702
2016-10-22 22:13:51 +02:00
parent b2c7faac6f
commit d547098ce8

View File

@@ -59,7 +59,7 @@ public class ReplayHandler {
*/ */
private boolean suppressCameraMovements; private boolean suppressCameraMovements;
private final Set<Marker> markers; private final List<Marker> markers;
private final GuiReplayOverlay overlay; private final GuiReplayOverlay overlay;
@@ -78,7 +78,7 @@ public class ReplayHandler {
FMLCommonHandler.instance().bus().post(new ReplayOpenEvent.Pre(this)); FMLCommonHandler.instance().bus().post(new ReplayOpenEvent.Pre(this));
markers = new HashSet<>(replayFile.getMarkers().or(Collections.<Marker>emptySet())); markers = new ArrayList<>(replayFile.getMarkers().or(Collections.emptySet()));
replaySender = new ReplaySender(this, replayFile, asyncMode); replaySender = new ReplaySender(this, replayFile, asyncMode);
@@ -185,9 +185,9 @@ public class ReplayHandler {
/** /**
* Returns all markers. * Returns all markers.
* When changed, {@link #saveMarkers()} should be called to save the changes. * When changed, {@link #saveMarkers()} should be called to save the changes.
* @return Set of markers * @return Collection of markers in no particular order
*/ */
public Set<Marker> getMarkers() { public Collection<Marker> getMarkers() {
return markers; return markers;
} }
@@ -196,7 +196,7 @@ public class ReplayHandler {
*/ */
public void saveMarkers() { public void saveMarkers() {
try { try {
replayFile.writeMarkers(markers); replayFile.writeMarkers(new HashSet<>(markers));
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }