From 798a13f3a7a48df3bdec1b156f60b27a6536e957 Mon Sep 17 00:00:00 2001 From: LeafHacker Date: Sat, 2 Jan 2021 17:46:24 +0000 Subject: [PATCH] Fix NPE while checking whether to disable button shouldInstallButtonBeEnabled() switches on OptiFineSetting's value if OptiFineToggleSetting is enabled. However OptiFineSetting's value is null when OptiFine isn't supported by the current installation mode. Fixes #117 --- CHANGELOG.md | 3 +++ .../installer/gui/pages/MainPage.java | 12 ++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b4b21b..08328b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixes +- Fix error checking whether to enable the Install button when OptiFine is enabled but not supported ([#117](https://github.com/ImpactDevelopment/Installer/issues/117)) + ## [0.9.3] - 2020-08-28 ### Added diff --git a/src/main/java/io/github/ImpactDevelopment/installer/gui/pages/MainPage.java b/src/main/java/io/github/ImpactDevelopment/installer/gui/pages/MainPage.java index c4deaf7..b80a75c 100644 --- a/src/main/java/io/github/ImpactDevelopment/installer/gui/pages/MainPage.java +++ b/src/main/java/io/github/ImpactDevelopment/installer/gui/pages/MainPage.java @@ -139,10 +139,14 @@ public MainPage(AppWindow app) { private boolean shouldInstallButtonBeEnabled(InstallationConfig config) { if (config.getSettingValue(OptiFineToggleSetting.INSTANCE)) { - switch (config.getSettingValue(OptiFineSetting.INSTANCE)) { - case MISSING: - case CUSTOM: - return Files.isRegularFile(config.getSettingValue(OptiFineFileSetting.INSTANCE)); + // OptiFineSetting's value is null when the installation mode doesn't support optifine + String optifine = config.getSettingValue(OptiFineSetting.INSTANCE); + if (optifine != null) { + switch (optifine) { + case MISSING: + case CUSTOM: + return Files.isRegularFile(config.getSettingValue(OptiFineFileSetting.INSTANCE)); + } } } return true;