aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/dev/mayaqq/ygasi/registry/PlayerDataRegistry.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/dev/mayaqq/ygasi/registry/PlayerDataRegistry.java')
-rw-r--r--src/main/java/dev/mayaqq/ygasi/registry/PlayerDataRegistry.java78
1 files changed, 0 insertions, 78 deletions
diff --git a/src/main/java/dev/mayaqq/ygasi/registry/PlayerDataRegistry.java b/src/main/java/dev/mayaqq/ygasi/registry/PlayerDataRegistry.java
deleted file mode 100644
index d3fd387..0000000
--- a/src/main/java/dev/mayaqq/ygasi/registry/PlayerDataRegistry.java
+++ /dev/null
@@ -1,78 +0,0 @@
-package dev.mayaqq.ygasi.registry;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.annotations.SerializedName;
-import net.fabricmc.loader.api.FabricLoader;
-
-import java.io.*;
-import java.util.*;
-
-public class PlayerDataRegistry {
- public static PlayerData PLAYERDATA = new PlayerData();
- public static EmptyPlayerData EMPTYPLAYERDATA = new EmptyPlayerData();
- private static final Gson gson = new GsonBuilder().setPrettyPrinting().create();
-
-
- public static void load(UUID uuid) {
- //this isnt working :sob:
- File playerDataFolder = new File(FabricLoader.getInstance().getGameDir().toFile(), "ygasi");
- File playerDatFile = new File(FabricLoader.getInstance().getGameDir().toFile() + "/ygasi/" + uuid + ".json");
- if (!playerDataFolder.exists()) {
- playerDataFolder.mkdir();
- }
- if (!playerDatFile.exists()) {
- try {
- playerDatFile.createNewFile();
- saveEmpty(uuid);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- } else {
- try {
- PLAYERDATA = gson.fromJson(new FileReader(playerDatFile), PlayerData.class);
- } catch (FileNotFoundException e) {
- throw new RuntimeException(e);
- }
- }
- }
-
- public static void save(UUID uuid) {
- try {
- File playerDatFile = new File(FabricLoader.getInstance().getGameDir().toFile() + "/ygasi/" + uuid + ".json");
- var writer = new FileWriter(playerDatFile);
- writer.write(gson.toJson(PLAYERDATA));
- writer.close();
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
- public static void saveEmpty(UUID uuid) {
- try {
- File playerDatFile = new File(FabricLoader.getInstance().getGameDir().toFile() + "/ygasi/" + uuid + ".json");
- var writer = new FileWriter(playerDatFile);
- writer.write(gson.toJson(EMPTYPLAYERDATA));
- writer.close();
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
- public static class PlayerData {
- @SerializedName("branches")
- public static Map<String, Boolean> branches = new HashMap<>();
- @SerializedName("skills")
- public static Map<String, Integer> skills = new HashMap<>();
-
- public PlayerData() {}
- }
-
- public static class EmptyPlayerData {
- @SerializedName("branches")
- public static Map<String, Boolean> branches = new HashMap<>();
- @SerializedName("skills")
- public static Map<String, Integer> skills = new HashMap<>();
-
- public EmptyPlayerData() {}
- }
-} \ No newline at end of file