Settings agnostic to invalid configuation file

This commit is contained in:
François Autin 2021-06-10 14:02:48 +02:00
parent 264f53f88d
commit 677e4dd013
No known key found for this signature in database
GPG Key ID: 24025429AC559B7C

View File

@ -22,19 +22,22 @@ public class Settings {
public void setSettings() throws Exception {
HashMap<String, Object> set = Launcher.pointer.getArraysettings();
int width = (Integer) set.get("width");
int height = (Integer) set.get("height");
int rounds = (Integer) set.get("rounds");
boolean fullscreen = (Boolean) set.get("fullscreen");
String character1 = (String) set.get("character1");
String character2 = (String) set.get("character2");
String stage = (String) set.get("stage");
try {
int width = (Integer) set.get("width");
int height = (Integer) set.get("height");
int rounds = (Integer) set.get("rounds");
boolean fullscreen = (Boolean) set.get("fullscreen");
String character1 = (String) set.get("character1");
String character2 = (String) set.get("character2");
String stage = (String) set.get("stage");
config.write(width, height, rounds, fullscreen, character1, character2, stage);
} catch (Exception e) {
e.printStackTrace();
config.write(800, 600, 3, false, "default", "default", "default");
System.out.println("Incorrect config file");
}
}
public String getResolution() {
return "" + Integer.toString(config.width) + "x" + Integer.toString(config.height);
}
}