Skip to content

Commit

Permalink
Fixed Bug on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
n0eL1405 committed Jun 29, 2023
1 parent 4d7559b commit 6d139d9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
<properties>
<java.version>11</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<app.version>1.4.0</app.version>
<app.version>1.4.1</app.version>
<app.versionString>v${app.version}</app.versionString>
<lombok.version>1.18.26</lombok.version>
<maven.compiler.target>${java.version}</maven.compiler.target>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<properties>
<java.version>11</java.version>
<app.version>1.5.0</app.version>
<app.version>1.4.1</app.version>
<app.versionString>v${app.version}</app.versionString>
<app.output.name>BSTCGF</app.output.name>

Expand Down
30 changes: 16 additions & 14 deletions src/main/java/de/leon/bstcgf/Profile.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.Scanner;
import java.util.*;
import java.util.stream.Collectors;

public class Profile {
Expand Down Expand Up @@ -49,11 +46,11 @@ private void init() {
}

if (file.exists()) {
try {
loadData(file);
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
try {
loadData(file);
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
} else {
initNewProfile(file);
}
Expand Down Expand Up @@ -276,11 +273,16 @@ public enum Setting {
}

public static List<ProfileData> getAllProfils() {
return Arrays.stream(
Objects.requireNonNull(new File(PROFILE_FOLDER).listFiles(File::isFile)))
// a little bit sketchy but it should work
.map(f -> new ProfileData(f.getName().replace(".json", "").replace("_", " ")))
.collect(Collectors.toList());
List<ProfileData> profiles = new LinkedList<>();

try {
profiles = Arrays.stream(
Objects.requireNonNull(new File(PROFILE_FOLDER).listFiles(File::isFile)))
// a little bit sketchy but it should work
.map(f -> new ProfileData(f.getName().replace(".json", "").replace("_", " ")))
.collect(Collectors.toList());
} catch (NullPointerException ignore) {}
return profiles;
}

@Data
Expand Down

0 comments on commit 6d139d9

Please sign in to comment.