aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/dev
diff options
context:
space:
mode:
authorMaximusbarcz <maxim.baranek@gmail.com>2022-10-19 18:42:37 +0200
committerMaximusbarcz <maxim.baranek@gmail.com>2022-10-19 18:42:37 +0200
commit0a587147d29dc0bc0fd5aeb98a67e3d76719b0d9 (patch)
tree5cc3bac4c57e8b7cb57743ef323a79a255e9f8fe /src/main/java/dev
parent11e5e2ddc52c8db91738204afef06d8a93b0f986 (diff)
downloadygasi-0a587147d29dc0bc0fd5aeb98a67e3d76719b0d9.tar.gz
ygasi-0a587147d29dc0bc0fd5aeb98a67e3d76719b0d9.tar.bz2
ygasi-0a587147d29dc0bc0fd5aeb98a67e3d76719b0d9.zip
reclaim ygasi from the leftoids (Please help this is not working code im just commiting so I can work on this when I get to italy AAAAAAAAAAAAA)
Diffstat (limited to 'src/main/java/dev')
-rw-r--r--src/main/java/dev/mayaqq/ygasi/CreatePlayerData.java54
-rw-r--r--src/main/java/dev/mayaqq/ygasi/registry/CommandRegistry.java11
-rw-r--r--src/main/java/dev/mayaqq/ygasi/registry/ConfigRegistry.java30
-rw-r--r--src/main/java/dev/mayaqq/ygasi/util/updatePlayerData.java17
-rw-r--r--src/main/java/dev/mayaqq/ygasi/ygasi.java1
5 files changed, 67 insertions, 46 deletions
diff --git a/src/main/java/dev/mayaqq/ygasi/CreatePlayerData.java b/src/main/java/dev/mayaqq/ygasi/CreatePlayerData.java
new file mode 100644
index 0000000..0444060
--- /dev/null
+++ b/src/main/java/dev/mayaqq/ygasi/CreatePlayerData.java
@@ -0,0 +1,54 @@
+package dev.mayaqq.ygasi;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import net.fabricmc.loader.api.FabricLoader;
+
+import java.io.*;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+public class CreatePlayerData {
+ public static UUID playerId;
+ private static File serverDatFile = new File(FabricLoader.getInstance().getConfigDir().toFile() + "/ygasi","serverDat.json");
+ public static ServerData SERVERDATA = new ServerData();
+ private static final Gson gson = new GsonBuilder().setPrettyPrinting().create();
+
+ public static void load() {
+ if (!serverDatFile.exists()) {
+ try {
+ serverDatFile.createNewFile();
+ } 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 createPlayerData(UUID player) throws IOException {
+ try {
+ playerId = player;
+ Map<UUID, Map<Integer, Map<String, Integer>>> uuidMap = new HashMap<>();
+ Map<Integer, Map<String, Integer>> tree = new HashMap<>();
+ Map<String, Integer> skills = new HashMap<>();
+ skills.put("0", 0);
+ for (int i = 1; i < 4; i++) {
+
+ }
+ var Writer = new FileWriter(serverDatFile);
+ Writer.write(gson.toJson(SERVERDATA));
+ Writer.close();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ public static class ServerData {
+ UUID player = null;
+ public ServerData() {}
+ }
+}
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() {}
- }
}
diff --git a/src/main/java/dev/mayaqq/ygasi/util/updatePlayerData.java b/src/main/java/dev/mayaqq/ygasi/util/updatePlayerData.java
deleted file mode 100644
index 6a8dd7e..0000000
--- a/src/main/java/dev/mayaqq/ygasi/util/updatePlayerData.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package dev.mayaqq.ygasi.util;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import net.minecraft.server.command.ServerCommandSource;
-import net.minecraft.server.network.ServerPlayerEntity;
-
-import java.util.Map;
-import java.util.UUID;
-
-import static dev.mayaqq.ygasi.ygasi.LOGGER;
-
-public class updatePlayerData {
- public static void createPlayerData(UUID player) {
- LOGGER.info(player.toString());
- }
-}
diff --git a/src/main/java/dev/mayaqq/ygasi/ygasi.java b/src/main/java/dev/mayaqq/ygasi/ygasi.java
index 81f2b5b..d0ab984 100644
--- a/src/main/java/dev/mayaqq/ygasi/ygasi.java
+++ b/src/main/java/dev/mayaqq/ygasi/ygasi.java
@@ -17,6 +17,7 @@ public class ygasi implements ModInitializer {
StatRegistry.skillRegister();
CommandRegistry.RegisterCommands();
ConfigRegistry.load();
+ CreatePlayerData.load();
LOGGER.info("You've got a skill issue!");
}
}