Fixed auto-loading when deleting a profile
This commit is contained in:
@@ -46,7 +46,7 @@ public final class Profile {
|
||||
}
|
||||
|
||||
public Profile(String name) {
|
||||
this(name, IOUtils.currentDir().getPath());
|
||||
this(name, new File(IOUtils.currentDir(), ".minecraft").getPath());
|
||||
}
|
||||
|
||||
public Profile(String name, String gameDir) {
|
||||
|
||||
@@ -58,8 +58,6 @@ public final class Settings {
|
||||
DownloadType.setSuggestedDownloadType(SETTINGS.getDownloadSource());
|
||||
if (!getProfiles().containsKey(DEFAULT_PROFILE))
|
||||
getProfiles().put(DEFAULT_PROFILE, new Profile(DEFAULT_PROFILE));
|
||||
if (!getProfiles().containsKey(HOME_PROFILE))
|
||||
getProfiles().put(HOME_PROFILE, new Profile(HOME_PROFILE, MCUtils.getLocation().getPath()));
|
||||
|
||||
for (Map.Entry<String, Profile> entry : getProfiles().entrySet()) {
|
||||
Profile e = entry.getValue();
|
||||
@@ -85,8 +83,11 @@ public final class Settings {
|
||||
} catch (IOException | JsonSyntaxException e) {
|
||||
HMCLog.warn("Something happened wrongly when load settings.", e);
|
||||
}
|
||||
else
|
||||
else {
|
||||
HMCLog.log("No settings file here, may be first loading.");
|
||||
if (!c.getConfigurations().containsKey(HOME_PROFILE))
|
||||
c.getConfigurations().put(HOME_PROFILE, new Profile(HOME_PROFILE, MCUtils.getLocation().getPath()));
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
@@ -154,7 +155,13 @@ public final class Settings {
|
||||
MessageBox.Show(C.i18n("settings.cannot_remove_default_config"));
|
||||
return false;
|
||||
}
|
||||
return getProfiles().remove(ver) != null;
|
||||
boolean notify = false;
|
||||
if (getLastProfile().getName().equals(ver))
|
||||
notify = true;
|
||||
boolean flag = getProfiles().remove(ver) != null;
|
||||
if (notify && flag)
|
||||
onProfileChanged();
|
||||
return flag;
|
||||
}
|
||||
|
||||
public static final EventHandler<Profile> profileChangedEvent = new EventHandler(null);
|
||||
|
||||
@@ -949,8 +949,7 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
private void btnRemoveProfileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRemoveProfileActionPerformed
|
||||
if (MessageBox.Show(C.i18n("ui.message.sure_remove", Settings.getLastProfile().getName()), MessageBox.YES_NO_OPTION) == MessageBox.NO_OPTION)
|
||||
return;
|
||||
if (Settings.delProfile(Settings.getLastProfile()))
|
||||
loadProfiles();
|
||||
Settings.delProfile(Settings.getLastProfile());
|
||||
}//GEN-LAST:event_btnRemoveProfileActionPerformed
|
||||
|
||||
private void cboVersionsItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cboVersionsItemStateChanged
|
||||
|
||||
Reference in New Issue
Block a user