1
0
forked from Clones/Controlify

fix many crashes

This commit is contained in:
isXander
2023-04-21 16:43:34 +01:00
parent 996dd47cf4
commit 3c24bd4bb7
5 changed files with 24 additions and 12 deletions

View File

@ -6,6 +6,7 @@ import dev.isxander.controlify.controller.Controller;
import dev.isxander.controlify.controller.joystick.CompoundJoystickInfo;
import dev.isxander.controlify.utils.DebugLog;
import net.fabricmc.loader.api.FabricLoader;
import org.jetbrains.annotations.Nullable;
import java.io.IOException;
import java.nio.file.Files;
@ -125,7 +126,8 @@ public class ControlifyConfig {
.collect(Collectors.toMap(info -> info.type().mappingId(), Function.identity()));
if (object.has("current_controller")) {
currentControllerUid = object.get("current_controller").getAsString();
JsonElement element = object.get("current_controller");
currentControllerUid = element.isJsonNull() ? null : element.getAsString();
} else {
currentControllerUid = controlify.getCurrentController().map(Controller::uid).orElse(null);
setDirty();
@ -177,6 +179,7 @@ public class ControlifyConfig {
return firstLaunch;
}
@Nullable
public String currentControllerUid() {
return currentControllerUid;
}