Fixed activation of mods not working. Closes #259

This commit is contained in:
huangyuhui
2018-02-14 15:16:42 +08:00
parent c9e7bf7ca5
commit 552238676c
2 changed files with 15 additions and 7 deletions

View File

@@ -87,12 +87,14 @@ public final class LauncherHelper {
.then(Task.of(Schedulers.javafx(), () -> emitStatus(LoadingState.LOGGING_IN))) .then(Task.of(Schedulers.javafx(), () -> emitStatus(LoadingState.LOGGING_IN)))
.then(Task.of(Main.i18n("account.methods"), variables -> { .then(Task.of(Main.i18n("account.methods"), variables -> {
try { try {
variables.set("account", account.logIn(new SpecificCharacterSelector(Accounts.getCurrentCharacter(account)), Settings.INSTANCE.getProxy())); try {
} catch (ServerDisconnectException e) { variables.set("account", account.logIn(new SpecificCharacterSelector(Accounts.getCurrentCharacter(account)), Settings.INSTANCE.getProxy()));
if (account.canPlayOffline()) } catch (ServerDisconnectException e) {
variables.set("account", account.playOffline()); if (account.canPlayOffline())
else variables.set("account", account.playOffline());
throw e; else
throw e;
}
} catch (AuthenticationException e) { } catch (AuthenticationException e) {
variables.set("account", DialogController.logIn(account)); variables.set("account", DialogController.logIn(account));
JFXUtilities.runInFX(() -> Controllers.dialog(launchingStepsPane)); JFXUtilities.runInFX(() -> Controllers.dialog(launchingStepsPane));

View File

@@ -19,6 +19,7 @@ package org.jackhuang.hmcl.mod;
import org.jackhuang.hmcl.util.FileUtils; import org.jackhuang.hmcl.util.FileUtils;
import org.jackhuang.hmcl.util.ImmediateBooleanProperty; import org.jackhuang.hmcl.util.ImmediateBooleanProperty;
import org.jackhuang.hmcl.util.Logging;
import org.jackhuang.hmcl.util.StringUtils; import org.jackhuang.hmcl.util.StringUtils;
import java.io.File; import java.io.File;
@@ -59,11 +60,16 @@ public final class ModInfo implements Comparable<ModInfo> {
activeProperty = new ImmediateBooleanProperty(this, "active", !DISABLED_EXTENSION.equals(FileUtils.getExtension(file))) { activeProperty = new ImmediateBooleanProperty(this, "active", !DISABLED_EXTENSION.equals(FileUtils.getExtension(file))) {
@Override @Override
protected void invalidated() { protected void invalidated() {
File f = file.getAbsoluteFile(), newF; File f = ModInfo.this.file.getAbsoluteFile(), newF;
if (DISABLED_EXTENSION.equals(FileUtils.getExtension(f))) if (DISABLED_EXTENSION.equals(FileUtils.getExtension(f)))
newF = new File(f.getParentFile(), FileUtils.getNameWithoutExtension(f)); newF = new File(f.getParentFile(), FileUtils.getNameWithoutExtension(f));
else else
newF = new File(f.getParentFile(), f.getName() + ".disabled"); newF = new File(f.getParentFile(), f.getName() + ".disabled");
if (f.renameTo(newF))
ModInfo.this.file = newF;
else
Logging.LOG.severe("Unable to rename file " + f + " to " + newF);
} }
}; };