diff options
author | Maximusbarcz <maxim.baranek@gmail.com> | 2022-12-22 19:06:44 +0100 |
---|---|---|
committer | Maximusbarcz <maxim.baranek@gmail.com> | 2022-12-22 19:06:44 +0100 |
commit | fd350ad15aa2f82b6b0afe3b13d283c45f4a7082 (patch) | |
tree | edb092151d025de570d32969a15b02922b86596f /src/main | |
parent | 3f4b8a506d46a3fc558d6941a31af1b69b4cede7 (diff) | |
download | ygasi-fd350ad15aa2f82b6b0afe3b13d283c45f4a7082.tar.gz ygasi-fd350ad15aa2f82b6b0afe3b13d283c45f4a7082.tar.bz2 ygasi-fd350ad15aa2f82b6b0afe3b13d283c45f4a7082.zip |
Did some more trolling
Diffstat (limited to 'src/main')
5 files changed, 23 insertions, 11 deletions
diff --git a/src/main/java/dev/mayaqq/ygasi/gui/BranchGui.java b/src/main/java/dev/mayaqq/ygasi/gui/BranchGui.java index 7039eff..c7b9950 100644 --- a/src/main/java/dev/mayaqq/ygasi/gui/BranchGui.java +++ b/src/main/java/dev/mayaqq/ygasi/gui/BranchGui.java @@ -19,9 +19,9 @@ import static dev.mayaqq.ygasi.registry.StatRegistry.SKILL_POINTS; public class BranchGui { public static void gui(ServerPlayerEntity player) { - UUID playerUUID = player.getUuid(); - PlayerDataRegistry.load(playerUUID); try { + UUID playerUUID = player.getUuid(); + PlayerDataRegistry.load(playerUUID); SimpleGui gui = new SimpleGui(ScreenHandlerType.GENERIC_9X3, player, false) {}; gui.setTitle(Text.of("§3Skill Points: " + player.getStatHandler().getStat(Stats.CUSTOM.getOrCreateStat(SKILL_POINTS)))); diff --git a/src/main/java/dev/mayaqq/ygasi/registry/CommandRegistry.java b/src/main/java/dev/mayaqq/ygasi/registry/CommandRegistry.java index 93ccbbd..190002b 100644 --- a/src/main/java/dev/mayaqq/ygasi/registry/CommandRegistry.java +++ b/src/main/java/dev/mayaqq/ygasi/registry/CommandRegistry.java @@ -70,6 +70,15 @@ public class CommandRegistry { context.getSource().sendMessage(Text.literal("§a" + player.getEntityName() + " has " + player.getStatHandler().getStat(Stats.CUSTOM.getOrCreateStat(SKILL_POINTS)) + " Unspent Skill Points.")); return 1; }))) - )); + .then(literal("config") + .then(literal("reload") + .executes(context -> { + ConfigRegistry.load(); + context.getSource().sendMessage(Text.literal("§aConfig reloaded!")); + return 1; + }))) + + ) + ); } }
\ No newline at end of file diff --git a/src/main/java/dev/mayaqq/ygasi/registry/ConfigRegistry.java b/src/main/java/dev/mayaqq/ygasi/registry/ConfigRegistry.java index 9e5c075..f6e0c82 100644 --- a/src/main/java/dev/mayaqq/ygasi/registry/ConfigRegistry.java +++ b/src/main/java/dev/mayaqq/ygasi/registry/ConfigRegistry.java @@ -15,7 +15,6 @@ public class ConfigRegistry { public static Config CONFIG = new Config(); static File modConfFolder = new File(FabricLoader.getInstance().getConfigDir().toFile(),"ygasi"); - private static final File serverDatFile = new File(FabricLoader.getInstance().getConfigDir().toFile() + "/ygasi/players"); private static File configFile = new File(modConfFolder,"config.json"); private static final Gson gson = new GsonBuilder().setPrettyPrinting().create(); @@ -24,9 +23,6 @@ public class ConfigRegistry { if (!modConfFolder.exists()) { modConfFolder.mkdir(); } - if (!serverDatFile.exists()) { - serverDatFile.mkdir(); - } if (!configFile.exists()) { try { configFile.createNewFile(); diff --git a/src/main/java/dev/mayaqq/ygasi/registry/PlayerDataRegistry.java b/src/main/java/dev/mayaqq/ygasi/registry/PlayerDataRegistry.java index 620ee89..811d8e0 100644 --- a/src/main/java/dev/mayaqq/ygasi/registry/PlayerDataRegistry.java +++ b/src/main/java/dev/mayaqq/ygasi/registry/PlayerDataRegistry.java @@ -4,6 +4,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.annotations.SerializedName; import net.fabricmc.loader.api.FabricLoader; +import net.minecraft.server.MinecraftServer; import java.io.*; import java.util.*; @@ -14,7 +15,12 @@ public class PlayerDataRegistry { public static void load(UUID uuid) { - File playerDatFile = new File(FabricLoader.getInstance().getConfigDir().toFile() + "/ygasi/players/" + uuid + ".json"); + //this isnt working :sob: + File playerDataFolder = new File(MinecraftServer::getSavePath, "ygasi"); + File playerDatFile = new File(FabricLoader.getInstance().getGameDir().toFile() + "/ygasi/" + uuid + ".json"); + if (!playerDataFolder.exists()) { + playerDataFolder.mkdir(); + } if (!playerDatFile.exists()) { try { playerDatFile.createNewFile(); @@ -33,7 +39,7 @@ public class PlayerDataRegistry { public static void save(UUID uuid) { try { - File playerDatFile = new File(FabricLoader.getInstance().getConfigDir().toFile() + "/ygasi/players/" + uuid + ".json"); + File playerDatFile = new File(FabricLoader.getInstance().getGameDir().toFile() + "/ygasi/" + uuid + ".json"); var writer = new FileWriter(playerDatFile); writer.write(gson.toJson(PLAYERDATA)); writer.close(); @@ -46,7 +52,8 @@ public class PlayerDataRegistry { @SerializedName("branches") public Map<String, Boolean> branches = new HashMap<>(); @SerializedName("skills") - public Map<String, Integer> skills = new HashMap<>(); + public Map<String, Map<String, Integer>> skills = new HashMap<>(); + public PlayerData() {} } }
\ No newline at end of file diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 3d70f3b..23cfe76 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -16,7 +16,7 @@ "license": "LGPL-3", "icon": "assets/ygasi/icon.png", - "environment": "*", + "environment": "server", "entrypoints": { "main": [ "dev.mayaqq.ygasi.Ygasi" |