aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/dev/mayaqq/ygasi/registry
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/dev/mayaqq/ygasi/registry')
-rw-r--r--src/main/java/dev/mayaqq/ygasi/registry/CommandRegistry.java11
-rw-r--r--src/main/java/dev/mayaqq/ygasi/registry/ConfigRegistry.java30
2 files changed, 12 insertions, 29 deletions
diff --git a/src/main/java/dev/mayaqq/ygasi/registry/CommandRegistry.java b/src/main/java/dev/mayaqq/ygasi/registry/CommandRegistry.java
index b386727..2d29443 100644
--- a/src/main/java/dev/mayaqq/ygasi/registry/CommandRegistry.java
+++ b/src/main/java/dev/mayaqq/ygasi/registry/CommandRegistry.java
@@ -1,7 +1,7 @@
package dev.mayaqq.ygasi.registry;
import com.mojang.brigadier.arguments.IntegerArgumentType;
-import dev.mayaqq.ygasi.util.updatePlayerData;
+import dev.mayaqq.ygasi.CreatePlayerData;
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
import net.minecraft.command.argument.EntityArgumentType;
import net.minecraft.server.command.CommandManager;
@@ -9,6 +9,8 @@ import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.stat.Stats;
import net.minecraft.text.Text;
+import java.io.IOException;
+
import static dev.mayaqq.ygasi.registry.StatRegistry.SKILL_POINTS;
import static net.minecraft.server.command.CommandManager.literal;
@@ -16,7 +18,12 @@ public class CommandRegistry {
public static void RegisterCommands() {
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> dispatcher.register(literal("skilltree")
.executes(context -> {
- updatePlayerData.createPlayerData(context.getSource().getPlayerOrThrow().getUuid());
+ try {
+ CreatePlayerData.createPlayerData(context.getSource().getPlayerOrThrow().getUuid());
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ context.getSource().sendMessage(Text.literal("§aSkillData Registered!"));
return 1;
})));
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> dispatcher.register(literal("ygasi")
diff --git a/src/main/java/dev/mayaqq/ygasi/registry/ConfigRegistry.java b/src/main/java/dev/mayaqq/ygasi/registry/ConfigRegistry.java
index 799506e..b34af4b 100644
--- a/src/main/java/dev/mayaqq/ygasi/registry/ConfigRegistry.java
+++ b/src/main/java/dev/mayaqq/ygasi/registry/ConfigRegistry.java
@@ -8,15 +8,14 @@ import java.io.*;
import java.nio.file.Files;
import java.util.HashMap;
import java.util.Map;
+import java.util.UUID;
public class ConfigRegistry {
public static Config CONFIG = new Config();
- public static ServerData SERVERDATA = new ServerData();
- private static File modConfFolder = new File(FabricLoader.getInstance().getConfigDir().toFile(),"ygasi");
+ static File modConfFolder = new File(FabricLoader.getInstance().getConfigDir().toFile(),"ygasi");
private static File configFile = new File(modConfFolder,"config.json");
- private static File serverDatFile = new File(modConfFolder,"serverDat.json");
private static final Gson gson = new GsonBuilder().setPrettyPrinting().create();
public static void load() {
@@ -39,20 +38,6 @@ public class ConfigRegistry {
throw new RuntimeException(e);
}
}
- if (!serverDatFile.exists()) {
- try {
- serverDatFile.createNewFile();
- saveServerData();
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- } else {
- try {
- SERVERDATA = gson.fromJson(new FileReader(serverDatFile), ServerData.class);
- } catch (FileNotFoundException e) {
- throw new RuntimeException(e);
- }
- }
}
public static void saveConfig() throws IOException {
@@ -61,19 +46,10 @@ public class ConfigRegistry {
writer.write(gson.toJson(CONFIG));
writer.close();
}
- public static void saveServerData() throws IOException {
- var Writer = new FileWriter(serverDatFile);
- Writer.write(gson.toJson(SERVERDATA));
- Writer.close();
- }
+
public static class Config {
//the thing to write in the config file
public int pointsRewarded = 1;
public Config() {}
}
- public static class ServerData {
- //the things to write in the serverData file, this is only temporary for now
- public String Comment = "This File should store all the data for the players when they open the gui. Maybe this will get removed when I learn SQL? (never)";
- public ServerData() {}
- }
}