From 210e5a7edbee4bb280e869b7727d80bc0de30f82 Mon Sep 17 00:00:00 2001 From: B1n_ry Date: Fri, 17 Nov 2023 14:38:11 +0100 Subject: [PATCH] Replaced jankson with gson to fix config loading issue --- CHANGELOG.md | 3 +++ src/main/java/com/b1n_ry/yigd/Yigd.java | 3 ++- .../java/com/b1n_ry/yigd/config/YigdConfig.java | 17 ++++++++--------- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 17889a9f..7ac9cd46 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,9 +3,12 @@ ### Changes * Added config to drop contents of deleted graves, when deleted due to the max grave count reached. +* Config now uses GSON instead of jankson (config file is now yigd.json instead of yigd.json5) ### Fixes * Graves will no longer unlock when closing and reopening the game +* Added translation keys for enchantments +* Fixed error where game could not read config file, so you could not change the configs --- diff --git a/src/main/java/com/b1n_ry/yigd/Yigd.java b/src/main/java/com/b1n_ry/yigd/Yigd.java index 63b3fd8d..091fb32b 100644 --- a/src/main/java/com/b1n_ry/yigd/Yigd.java +++ b/src/main/java/com/b1n_ry/yigd/Yigd.java @@ -15,6 +15,7 @@ import com.b1n_ry.yigd.packets.ServerPacketHandler; import com.b1n_ry.yigd.util.YigdResourceHandler; import me.shedaniel.autoconfig.AutoConfig; +import me.shedaniel.autoconfig.serializer.GsonConfigSerializer; import me.shedaniel.autoconfig.serializer.JanksonConfigSerializer; import net.fabricmc.api.ModInitializer; import net.fabricmc.fabric.api.item.v1.FabricItemSettings; @@ -61,7 +62,7 @@ public class Yigd implements ModInitializer { @Override public void onInitialize() { - AutoConfig.register(YigdConfig.class, JanksonConfigSerializer::new); + AutoConfig.register(YigdConfig.class, GsonConfigSerializer::new); GRAVE_BLOCK_ENTITY = Registry.register(Registries.BLOCK_ENTITY_TYPE, new Identifier(MOD_ID, "grave_block_entity"), FabricBlockEntityTypeBuilder.create(GraveBlockEntity::new, GRAVE_BLOCK).build()); diff --git a/src/main/java/com/b1n_ry/yigd/config/YigdConfig.java b/src/main/java/com/b1n_ry/yigd/config/YigdConfig.java index 9809aa1e..f246d601 100644 --- a/src/main/java/com/b1n_ry/yigd/config/YigdConfig.java +++ b/src/main/java/com/b1n_ry/yigd/config/YigdConfig.java @@ -7,8 +7,6 @@ import me.shedaniel.autoconfig.annotation.Config; import me.shedaniel.autoconfig.annotation.ConfigEntry; import me.shedaniel.cloth.clothconfig.shadowed.blue.endless.jankson.Comment; -import net.minecraft.item.Item; -import net.minecraft.item.Items; import java.util.*; import java.util.concurrent.TimeUnit; @@ -51,9 +49,9 @@ public static class InventoryConfig { @ConfigEntry.Gui.CollapsibleObject public ItemLossConfig itemLoss = new ItemLossConfig(); // delete enchantments - public List vanishingEnchantments = List.of("minecraft:vanishing_curse"); + public List vanishingEnchantments = new ArrayList<>() {{ add("minecraft:vanishing_curse"); }}; // soulbinding enchantments - public List soulboundEnchantments = List.of("yigd:soulbound"); + public List soulboundEnchantments = new ArrayList<>() {{ add("yigd:soulbound"); }}; // loose soulbound level public boolean loseSoulboundLevelOnDeath = false; // void slots @@ -249,11 +247,12 @@ public static class Range { public static class BlockUnderGrave { public boolean enabled = true; - public List blockInDimensions = List.of( - new MapEntry("minecraft:overworld", "minecraft:cobblestone"), - new MapEntry("minecraft:nether", "minecraft:soul_soil"), - new MapEntry("minecraft:end", "minecraft:end_stone"), - new MapEntry("misc", "minecraft:dirt")); + public List blockInDimensions = new ArrayList<>() {{ + add(new MapEntry("minecraft:overworld", "minecraft:cobblestone")); + add(new MapEntry("minecraft:nether", "minecraft:soul_soil")); + add(new MapEntry("minecraft:end", "minecraft:end_stone")); + add(new MapEntry("misc", "minecraft:dirt")); + }}; public boolean generateOnProtectedLand = false; } }