diff --git a/dataLib-MOD/src/java/net/datalib/Main.hs b/dataLib-MOD/src/java/net/datalib/Main.hs new file mode 100644 index 0000000..09b3f05 --- /dev/null +++ b/dataLib-MOD/src/java/net/datalib/Main.hs @@ -0,0 +1,13 @@ +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import net.fabricmc.api.ModInitializer; + +public class Main implements ModInitializer { + public static final String MOD_ID = "datalib"; + public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID); + + @Override + public void onInitialize() { + LOGGER.info("Starting..."); + } +} diff --git a/dataLib-MOD/src/main/java/net/datalib/Main.java b/dataLib-MOD/src/main/java/net/datalib/Main.java deleted file mode 100644 index d498868..0000000 --- a/dataLib-MOD/src/main/java/net/datalib/Main.java +++ /dev/null @@ -1,97 +0,0 @@ -package net.datalib; - -import com.google.gson.Gson; -import com.google.gson.JsonObject; -import net.fabricmc.api.ModInitializer; -import net.fabricmc.fabric.api.resource.ResourceManagerHelper; -import net.fabricmc.fabric.api.resource.SimpleResourceReloadListener; -import net.minecraft.resources.Identifier; -import net.minecraft.server.packs.PackType; -import net.minecraft.server.packs.resources.ResourceManager; - -import java.io.BufferedReader; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.Executor; - -public class Main implements ModInitializer { - - public static final String MOD_ID = "datalib"; - private static final Gson GSON = new Gson(); - - public static final Map REGISTERED_FLAGS = new HashMap<>(); - - @Override - public void onInitialize() { - ResourceManagerHelper.get(PackType.SERVER_DATA) - .registerReloadListener(new FlagReloadListener()); - } - - private static class FlagReloadListener - implements SimpleResourceReloadListener> { - - @Override - public Identifier getFabricId() { - return Identifier.fromNamespaceAndPath(MOD_ID, "feature_flag_reload"); - } - - @Override - public CompletableFuture> load( - ResourceManager manager, - Executor executor - ) { - return CompletableFuture.supplyAsync(() -> { - - Map loaded = new HashMap<>(); - - manager.listResources( - "data_packs", - id -> id.getPath().endsWith(".json") - ).forEach((id, resource) -> { - - try (BufferedReader reader = resource.openAsReader()) { - - JsonObject json = GSON.fromJson(reader, JsonObject.class); - - if (json == null) { - return; - } - - if (!json.has("flag_name") || !json.has("enabled")) { - return; - } - - Identifier flagId = Identifier.fromNamespaceAndPath( - id.getNamespace(), - json.get("flag_name").getAsString() - ); - - loaded.put( - flagId, - json.get("enabled").getAsBoolean() - ); - - } catch (Exception e) { - e.printStackTrace(); - } - }); - - return loaded; - - }, executor); - } - - @Override - public CompletableFuture apply( - Map data, - ResourceManager manager, - Executor executor - ) { - return CompletableFuture.runAsync(() -> { - REGISTERED_FLAGS.clear(); - REGISTERED_FLAGS.putAll(data); - }, executor); - } - } -} \ No newline at end of file diff --git a/dataLib-MOD/src/main/resources/fabric.mod.json b/dataLib-MOD/src/main/resources/fabric.mod.json index e9eceef..7ed54eb 100644 --- a/dataLib-MOD/src/main/resources/fabric.mod.json +++ b/dataLib-MOD/src/main/resources/fabric.mod.json @@ -2,8 +2,11 @@ "schemaVersion": 1, "id": "datalib", "version": "6.0.0", + "name": "dataLib", + "description": "Optimized and modern continuation of the dataLib library engine for runtoolkit.", + "license": "MIT", "icon": "pack.png", - "environment": "*", + "environment": "server", "entrypoints": { "main": [ "net.datalib.Main" @@ -14,4 +17,4 @@ "java": ">=25", "fabric-api": "*" } -} \ No newline at end of file +} diff --git a/dataLib-MOD/src/main/resources/pack.mcmeta b/dataLib-MOD/src/main/resources/pack.mcmeta deleted file mode 100644 index c7cdf2f..0000000 --- a/dataLib-MOD/src/main/resources/pack.mcmeta +++ /dev/null @@ -1,61 +0,0 @@ -{ - "pack": { - "description": [ - { - "text": "D.L.", - "color": "#00ccff", - "bold": true, - "italic": false, - "extra": [ - { - "text": " | ", - "color": "#ff0000", - "bold": false, - "italic": false, - "underlined": false, - "strikethrough": false, - "obfuscated": false - }, - { - "text": "by runtoolkit", - "color": "#00ff33", - "bold": false, - "italic": false, - "extra": [ - " ", - { - "text": "| ", - "color": "#ff0000", - "bold": false, - "italic": false, - "underlined": false, - "strikethrough": false, - "obfuscated": false - }, - { - "text": "26.2", - "color": "#e3ff57", - "bold": false, - "italic": false, - "underlined": true - } - ] - } - ] - }, - { - "text": " | v6.0.0", - "color": "#ffaa00", - "bold": false, - "italic": false - } - ], - "min_format": [107, 88], - "max_format": [107, 88] - }, - "features": { - "enabled": [ - "minecraft:vanilla" - ] - } -}