Commit 686a5905 authored by Nico Eckes's avatar Nico Eckes

Fixed data saving issues

parent 608bcfc6
Pipeline #798 passed with stage
in 2 minutes and 52 seconds
......@@ -5,9 +5,7 @@ import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import org.jetbrains.annotations.NotNull;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.function.Function;
public class Group implements Comparable<Group> {
......@@ -50,10 +48,10 @@ public class Group implements Comparable<Group> {
public Map<String, Object> save() {
Map<String, Object> result = new HashMap<>();
result.put(KEY_PERMISSIONS, permissions);
result.put(KEY_INHERITS, inherits.get());
result.put(KEY_PREFIX, prefix.get());
result.put(KEY_SUFFIX, suffix.get());
if (!permissions.isEmpty()) result.put(KEY_PERMISSIONS, permissions);
if (inherits.get() != null) result.put(KEY_INHERITS, inherits.get().name);
if (prefix.get() != null) result.put(KEY_PREFIX, prefix.get());
if (suffix.get() != null) result.put(KEY_SUFFIX, suffix.get());
return result;
}
......
......@@ -46,10 +46,10 @@ public class Player implements Comparable<Player> {
public Map<String, Object> save() {
Map<String, Object> result = new HashMap<>();
result.put(KEY_PERMISSIONS, permissions);
result.put(KEY_GROUP, group.get());
result.put(KEY_PREFIX, prefix.get());
result.put(KEY_SUFFIX, suffix.get());
if (!permissions.isEmpty()) result.put(KEY_PERMISSIONS, permissions);
if (group.get() != null) result.put(KEY_GROUP, group.get().name);
if (prefix.get() != null) result.put(KEY_PREFIX, prefix.get());
if (suffix.get() != null) result.put(KEY_SUFFIX, suffix.get());
return result;
}
......
......@@ -49,6 +49,7 @@ public class MainScreen {
load(Paths.get("../groups.yml"), Paths.get("../players.yml"));
} catch (FileNotFoundException e1) {
System.out.println("empty");
load();
} catch (Exception e1) {
Utils.showExceptionAlert("Could not load data from parent directory", e);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment