Skip to content

Commit

Permalink
Switched to new default config load() method
Browse files Browse the repository at this point in the history
  • Loading branch information
LatvianModder committed Oct 31, 2021
1 parent a42a670 commit 2968c59
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 30 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ curseforge_id=410811
curseforge_type=release
jei_file=3109181
architectury_version=1.22.32
ftb_library_version=1605.3.4-build.77
ftb_library_version=1605.3.4-build.78
ftb_ranks_version=1605.1.4-build.12
41 changes: 13 additions & 28 deletions src/main/java/dev/ftb/mods/ftbessentials/FTBEEventHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import dev.ftb.mods.ftbessentials.util.TeleportPos;
import dev.ftb.mods.ftblibrary.snbt.SNBT;
import dev.ftb.mods.ftblibrary.snbt.SNBTCompoundTag;
import dev.ftb.mods.ftblibrary.snbt.config.SNBTConfig;
import me.shedaniel.architectury.hooks.LevelResourceHooks;
import me.shedaniel.architectury.platform.Platform;
import net.minecraft.ChatFormatting;
Expand All @@ -30,8 +29,6 @@
import net.minecraftforge.fml.event.server.FMLServerAboutToStartEvent;
import net.minecraftforge.fml.event.server.FMLServerStoppedEvent;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Iterator;

Expand All @@ -49,32 +46,20 @@ public static void serverAboutToStart(FMLServerAboutToStartEvent event) {
Path configFilePath = event.getServer().getWorldPath(CONFIG_FILE);
Path defaultConfigFilePath = Platform.getConfigFolder().resolve("../defaultconfigs/ftbessentials-server.snbt");

if (Files.exists(defaultConfigFilePath)) {
if (!Files.exists(configFilePath)) {
try {
Files.copy(defaultConfigFilePath, configFilePath);
} catch (IOException ex) {
ex.printStackTrace();
}
}
} else {
SNBTConfig defaultConfigFile = SNBTConfig.create(FTBEssentials.MOD_ID);
defaultConfigFile.comment("Default config file that will be copied to world's serverconfig/ftbessentials.snbt location");
defaultConfigFile.comment("Copy values you wish to override in here");
defaultConfigFile.comment("Example:");
defaultConfigFile.comment("");
defaultConfigFile.comment("{");
defaultConfigFile.comment(" misc: {");
defaultConfigFile.comment(" enderchest: {");
defaultConfigFile.comment(" enabled: false");
defaultConfigFile.comment(" }");
defaultConfigFile.comment(" }");
defaultConfigFile.comment("}");

defaultConfigFile.save(defaultConfigFilePath);
}
FTBEConfig.CONFIG.load(configFilePath, defaultConfigFilePath, () -> new String[]{
"Default config file that will be copied to world's serverconfig/ftbessentials.snbt location",
"Copy values you wish to override in here",
"Example:",
"",
"{",
" misc: {",
" enderchest: {",
" enabled: false",
" }",
" }",
"}",
});

FTBEConfig.CONFIG.load(configFilePath);
FTBEPlayerData.MAP.clear();
FTBEWorldData.instance = new FTBEWorldData(event.getServer());

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ side = "BOTH"
[[dependencies.ftbessentials]]
modId = "ftblibrary"
mandatory = true
versionRange = "[1605.3.4-build.77,)"
versionRange = "[1605.3.4-build.79,)"
ordering = "NONE"
side = "BOTH"

0 comments on commit 2968c59

Please sign in to comment.