mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-15 06:45:42 -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);
|
mms = new MinecraftModService(p, this);
|
||||||
mds = new MinecraftDownloadService(p, this);
|
mds = new MinecraftDownloadService(p, this);
|
||||||
mas = new MinecraftAssetService(p, this);
|
mas = new MinecraftAssetService(p, this);
|
||||||
refreshVersions();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public File getFolder() {
|
public File getFolder() {
|
||||||
@ -128,17 +127,16 @@ public class MinecraftVersionManager extends IMinecraftProvider {
|
|||||||
try {
|
try {
|
||||||
mcVersion = C.gson.fromJson(FileUtils.readFileToString(jsonFile), MinecraftVersion.class);
|
mcVersion = C.gson.fromJson(FileUtils.readFileToString(jsonFile), MinecraftVersion.class);
|
||||||
if (mcVersion == null)
|
if (mcVersion == null)
|
||||||
throw new RuntimeException("Wrong json format, got null.");
|
throw new GameException("Wrong json format, got null.");
|
||||||
} catch (IOException | RuntimeException e) {
|
} catch (IOException | GameException e) {
|
||||||
HMCLog.warn("Found wrong format json, try to fix it.", 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) {
|
if (MessageBox.Show(C.i18n("launcher.versions_json_not_formatted", id), MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION) {
|
||||||
refreshJson(id);
|
refreshJson(id);
|
||||||
try {
|
try {
|
||||||
mcVersion = C.gson.fromJson(FileUtils.readFileToString(jsonFile), MinecraftVersion.class);
|
mcVersion = C.gson.fromJson(FileUtils.readFileToString(jsonFile), MinecraftVersion.class);
|
||||||
if (mcVersion == null)
|
if (mcVersion == null)
|
||||||
throw new RuntimeException("Wrong json format, got null.");
|
throw new GameException("Wrong json format, got null.");
|
||||||
} catch (IOException | RuntimeException ex) {
|
} catch (IOException | GameException ex) {
|
||||||
HMCLog.err("Retried but still failed.");
|
|
||||||
HMCLog.warn("Ignoring: " + dir + ", the json of this Minecraft is malformed.", ex);
|
HMCLog.warn("Ignoring: " + dir + ", the json of this Minecraft is malformed.", ex);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -147,7 +145,7 @@ public class MinecraftVersionManager extends IMinecraftProvider {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (!id.equals(mcVersion.id)) {
|
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;
|
mcVersion.id = id;
|
||||||
FileUtils.writeQuietly(jsonFile, C.gsonPrettyPrinting.toJson(mcVersion));
|
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>//GEN-END:initComponents
|
||||||
// <editor-fold defaultstate="collapsed" desc="UI Events">
|
// <editor-fold defaultstate="collapsed" desc="UI Events">
|
||||||
private void cboProfilesItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cboProfilesItemStateChanged
|
private void cboProfilesItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cboProfilesItemStateChanged
|
||||||
if (!isLoading)
|
if (!isLoading) {
|
||||||
onSelected();
|
if (getProfile().getMinecraftProvider().getVersionCount() <= 0)
|
||||||
|
versionChanged(null);
|
||||||
|
prepare(getProfile());
|
||||||
|
}
|
||||||
}//GEN-LAST:event_cboProfilesItemStateChanged
|
}//GEN-LAST:event_cboProfilesItemStateChanged
|
||||||
|
|
||||||
private void btnNewProfileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNewProfileActionPerformed
|
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);
|
log(status, Level.WARN);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void log(String status, Level c) {
|
public synchronized void log(String status, Level c) {
|
||||||
status = status.replace("\t", " ");
|
status = status.replace("\t", " ");
|
||||||
Document d = txtLog.getStyledDocument();
|
Document d = txtLog.getStyledDocument();
|
||||||
SimpleAttributeSet sas = new SimpleAttributeSet();
|
SimpleAttributeSet sas = new SimpleAttributeSet();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user