Fix displaying "null" in GameItem

This commit is contained in:
huanghongxun 2019-08-19 14:57:42 +08:00
parent 0dd9dc6c17
commit e7142e4032
2 changed files with 7 additions and 5 deletions

View File

@ -25,6 +25,7 @@ import org.jackhuang.hmcl.setting.Profile;
import org.jackhuang.hmcl.ui.Controllers;
import org.jackhuang.hmcl.ui.wizard.WizardController;
import org.jackhuang.hmcl.ui.wizard.WizardProvider;
import org.jetbrains.annotations.NotNull;
import java.util.Map;
@ -38,7 +39,7 @@ public final class UpdateInstallerWizardProvider implements WizardProvider {
private final String libraryId;
private final String oldLibraryVersion;
public UpdateInstallerWizardProvider(Profile profile, String gameVersion, Version version, String libraryId, String oldLibraryVersion) {
public UpdateInstallerWizardProvider(@NotNull Profile profile, @NotNull String gameVersion, @NotNull Version version, @NotNull String libraryId, @NotNull String oldLibraryVersion) {
this.profile = profile;
this.gameVersion = gameVersion;
this.version = version;

View File

@ -60,10 +60,11 @@ public class GameItem extends Control {
StringBuilder libraries = new StringBuilder(game);
LibraryAnalyzer analyzer = LibraryAnalyzer.analyze(profile.getRepository().getResolvedPreservingPatchesVersion(id));
analyzer.forEachLibrary((libraryId, libraryVersion) -> {
if (I18n.hasKey("install.installer." + libraryId))
libraries
.append(", ").append(i18n("install.installer." + libraryId))
.append(": ").append(modifyVersion(game, libraryVersion.replaceAll("(?i)" + libraryId, "")));
if (I18n.hasKey("install.installer." + libraryId)) {
libraries.append(", ").append(i18n("install.installer." + libraryId));
if (libraryVersion != null)
libraries.append(": ").append(modifyVersion("", libraryVersion.replaceAll("(?i)" + libraryId, "")));
}
});
subtitle.set(libraries.toString());