Skip to content

Commit 6d6d24d

Browse files
fix crash when Vec2i configs lacked components
1 parent 6ce443c commit 6d6d24d

File tree

1 file changed

+6
-1
lines changed
  • enigma-swing/src/main/java/org/quiltmc/enigma/gui/config

1 file changed

+6
-1
lines changed

enigma-swing/src/main/java/org/quiltmc/enigma/gui/config/Config.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import java.awt.Point;
3333
import java.nio.file.Path;
3434
import java.nio.file.Paths;
35+
import java.util.Objects;
3536

3637
/**
3738
* Enigma config is separated into several {@value #FORMAT} files with names matching the methods used to access them:
@@ -237,7 +238,11 @@ public static Vec2i fromPoint(Point point) {
237238

238239
@Override
239240
public Vec2i convertFrom(ValueMap<Integer> representation) {
240-
return new Vec2i(representation.get("x"), representation.get("y"));
241+
final int defaultValue = Objects.requireNonNullElse(representation.getDefaultValue(), 0);
242+
return new Vec2i(
243+
representation.getOrDefault("x", defaultValue),
244+
representation.getOrDefault("y", defaultValue)
245+
);
241246
}
242247

243248
@Override

0 commit comments

Comments
 (0)