mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-14 06:17:47 -04:00
Fix 'refreshVersions' calling too many times
This commit is contained in:
parent
6c8c189b72
commit
9835aa4110
@ -63,7 +63,6 @@ public class MinecraftVersionManager extends IMinecraftProvider {
|
||||
mms = new MinecraftModService(p, this);
|
||||
mds = new MinecraftDownloadService(p, this);
|
||||
mas = new MinecraftAssetService(p, this);
|
||||
refreshVersions();
|
||||
}
|
||||
|
||||
public File getFolder() {
|
||||
@ -128,17 +127,16 @@ public class MinecraftVersionManager extends IMinecraftProvider {
|
||||
try {
|
||||
mcVersion = C.gson.fromJson(FileUtils.readFileToString(jsonFile), MinecraftVersion.class);
|
||||
if (mcVersion == null)
|
||||
throw new RuntimeException("Wrong json format, got null.");
|
||||
} catch (IOException | RuntimeException e) {
|
||||
throw new GameException("Wrong json format, got null.");
|
||||
} catch (IOException | GameException e) {
|
||||
HMCLog.warn("Found wrong format json, try to fix it.", e);
|
||||
if (MessageBox.Show(C.i18n("launcher.versions_json_not_formatted", id), MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION) {
|
||||
refreshJson(id);
|
||||
try {
|
||||
mcVersion = C.gson.fromJson(FileUtils.readFileToString(jsonFile), MinecraftVersion.class);
|
||||
if (mcVersion == null)
|
||||
throw new RuntimeException("Wrong json format, got null.");
|
||||
} catch (IOException | RuntimeException ex) {
|
||||
HMCLog.err("Retried but still failed.");
|
||||
throw new GameException("Wrong json format, got null.");
|
||||
} catch (IOException | GameException ex) {
|
||||
HMCLog.warn("Ignoring: " + dir + ", the json of this Minecraft is malformed.", ex);
|
||||
continue;
|
||||
}
|
||||
@ -147,7 +145,7 @@ public class MinecraftVersionManager extends IMinecraftProvider {
|
||||
}
|
||||
try {
|
||||
if (!id.equals(mcVersion.id)) {
|
||||
HMCLog.warn("Found: " + dir + ", it contains id: " + mcVersion.id + ", expected: " + id + ", the launcher will fix this problem.");
|
||||
HMCLog.warn("Found: " + dir + ", it contains id: " + mcVersion.id + ", expected: " + id + ", this app will fix this problem.");
|
||||
mcVersion.id = id;
|
||||
FileUtils.writeQuietly(jsonFile, C.gsonPrettyPrinting.toJson(mcVersion));
|
||||
}
|
||||
|
@ -884,8 +884,11 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
// <editor-fold defaultstate="collapsed" desc="UI Events">
|
||||
private void cboProfilesItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cboProfilesItemStateChanged
|
||||
if (!isLoading)
|
||||
onSelected();
|
||||
if (!isLoading) {
|
||||
if (getProfile().getMinecraftProvider().getVersionCount() <= 0)
|
||||
versionChanged(null);
|
||||
prepare(getProfile());
|
||||
}
|
||||
}//GEN-LAST:event_cboProfilesItemStateChanged
|
||||
|
||||
private void btnNewProfileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNewProfileActionPerformed
|
||||
|
@ -259,7 +259,7 @@ public class LogWindow extends javax.swing.JFrame {
|
||||
log(status, Level.WARN);
|
||||
}
|
||||
|
||||
public void log(String status, Level c) {
|
||||
public synchronized void log(String status, Level c) {
|
||||
status = status.replace("\t", " ");
|
||||
Document d = txtLog.getStyledDocument();
|
||||
SimpleAttributeSet sas = new SimpleAttributeSet();
|
||||
|
Loading…
x
Reference in New Issue
Block a user