try fix ConcurrentModificationException
This commit is contained in:
@@ -193,8 +193,7 @@ public final class MainPage extends StackPane implements DecoratorPage {
|
|||||||
private void loadVersions(Profile profile) {
|
private void loadVersions(Profile profile) {
|
||||||
this.profile = profile;
|
this.profile = profile;
|
||||||
List<Node> children = new LinkedList<>();
|
List<Node> children = new LinkedList<>();
|
||||||
List<Version> versions = new LinkedList<>(profile.getRepository().getVersions());
|
for (Version version : profile.getRepository().getVersions()) {
|
||||||
for (Version version : versions) {
|
|
||||||
children.add(buildNode(profile, version.getId(), GameVersion.minecraftVersion(profile.getRepository().getVersionJar(version.getId())).orElse("Unknown")));
|
children.add(buildNode(profile, version.getId(), GameVersion.minecraftVersion(profile.getRepository().getVersionJar(version.getId())).orElse("Unknown")));
|
||||||
}
|
}
|
||||||
FXUtils.resetChildren(masonryPane, children);
|
FXUtils.resetChildren(masonryPane, children);
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ import java.util.logging.Level;
|
|||||||
public class DefaultGameRepository implements GameRepository {
|
public class DefaultGameRepository implements GameRepository {
|
||||||
|
|
||||||
private File baseDirectory;
|
private File baseDirectory;
|
||||||
protected final Map<String, Version> versions = new TreeMap<>();
|
protected Map<String, Version> versions;
|
||||||
protected boolean loaded = false;
|
protected boolean loaded = false;
|
||||||
|
|
||||||
public DefaultGameRepository(File baseDirectory) {
|
public DefaultGameRepository(File baseDirectory) {
|
||||||
@@ -151,7 +151,7 @@ public class DefaultGameRepository implements GameRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void refreshVersionsImpl() {
|
protected void refreshVersionsImpl() {
|
||||||
versions.clear();
|
Map<String, Version> versions = new TreeMap<>();
|
||||||
|
|
||||||
if (ClassicVersion.hasClassicVersion(getBaseDirectory())) {
|
if (ClassicVersion.hasClassicVersion(getBaseDirectory())) {
|
||||||
Version version = new ClassicVersion();
|
Version version = new ClassicVersion();
|
||||||
@@ -172,7 +172,10 @@ public class DefaultGameRepository implements GameRepository {
|
|||||||
if (!json.exists()) {
|
if (!json.exists()) {
|
||||||
List<File> jsons = FileUtils.listFilesByExtension(dir, "json");
|
List<File> jsons = FileUtils.listFilesByExtension(dir, "json");
|
||||||
if (jsons.size() == 1)
|
if (jsons.size() == 1)
|
||||||
jsons.get(0).renameTo(json);
|
if (!jsons.get(0).renameTo(json)) {
|
||||||
|
Logging.LOG.warning("Cannot rename json file " + jsons.get(0) + " to " + json + ", ignoring version " + id);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Version version;
|
Version version;
|
||||||
@@ -216,6 +219,7 @@ public class DefaultGameRepository implements GameRepository {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.versions = versions;
|
||||||
loaded = true;
|
loaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user