diff --git a/gradle.properties b/gradle.properties index e803935aa..9df62adb4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,10 +3,10 @@ org.gradle.jvmargs=-Xmx1G maven_group=com.terraformersmc archive_name=modmenu -minecraft_version=23w42a -yarn_mappings=23w42a+build.1 -loader_version=0.14.23 -fabric_version=0.90.3+1.20.3 +minecraft_version=23w44a +yarn_mappings=23w44a+build.5 +loader_version=0.14.24 +fabric_version=0.90.7+1.20.3 quilt_loader_version=0.17.7 # Project Metadata @@ -20,7 +20,7 @@ default_release_type=stable # Modrinth Metadata modrinth_slug=modmenu modrinth_id=mOgUt4GM -modrinth_game_versions=23w42a +modrinth_game_versions=23w44a modrinth_mod_loaders=fabric, quilt # Mod Loader Metadata diff --git a/src/main/java/com/terraformersmc/modmenu/config/ModMenuConfigManager.java b/src/main/java/com/terraformersmc/modmenu/config/ModMenuConfigManager.java index c4464e827..c1b350aaf 100644 --- a/src/main/java/com/terraformersmc/modmenu/config/ModMenuConfigManager.java +++ b/src/main/java/com/terraformersmc/modmenu/config/ModMenuConfigManager.java @@ -14,17 +14,19 @@ import java.lang.reflect.Modifier; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; +import java.nio.file.Files; +import java.nio.file.Path; import java.util.Locale; import java.util.stream.Collectors; public class ModMenuConfigManager { - private static File file; + private static Path path; - private static void prepareConfigFile() { - if (file != null) { + private static void prepareConfigPath() { + if (path != null) { return; } - file = new File(FabricLoader.getInstance().getConfigDir().toFile(), ModMenu.MOD_ID + ".json"); + path = FabricLoader.getInstance().getConfigDir().resolve(ModMenu.MOD_ID + ".json"); } public static void initializeConfig() { @@ -33,14 +35,14 @@ public static void initializeConfig() { @SuppressWarnings("unchecked") private static void load() { - prepareConfigFile(); + prepareConfigPath(); try { - if (!file.exists()) { + if (!Files.exists(path)) { save(); } - if (file.exists()) { - BufferedReader br = new BufferedReader(new FileReader(file)); + if (Files.exists(path)) { + BufferedReader br = Files.newBufferedReader(path); JsonObject json = new JsonParser().parse(br).getAsJsonObject(); for (Field field : ModMenuConfig.class.getDeclaredFields()) { @@ -79,7 +81,7 @@ private static void load() { } } } - } catch (FileNotFoundException | IllegalAccessException e) { + } catch (IOException | IllegalAccessException e) { System.err.println("Couldn't load Mod Menu configuration file; reverting to defaults"); e.printStackTrace(); } @@ -88,7 +90,7 @@ private static void load() { @SuppressWarnings("unchecked") public static void save() { ModMenu.clearModCountCache(); - prepareConfigFile(); + prepareConfigPath(); JsonObject config = new JsonObject(); @@ -118,7 +120,7 @@ public static void save() { String jsonString = ModMenu.GSON.toJson(config); - try (FileWriter fileWriter = new FileWriter(file)) { + try (BufferedWriter fileWriter = Files.newBufferedWriter(path)) { fileWriter.write(jsonString); } catch (IOException e) { System.err.println("Couldn't save Mod Menu configuration file"); diff --git a/src/main/java/com/terraformersmc/modmenu/gui/ModsScreen.java b/src/main/java/com/terraformersmc/modmenu/gui/ModsScreen.java index e08188f00..3ea78dcc0 100644 --- a/src/main/java/com/terraformersmc/modmenu/gui/ModsScreen.java +++ b/src/main/java/com/terraformersmc/modmenu/gui/ModsScreen.java @@ -35,7 +35,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; @@ -244,7 +243,7 @@ public void render(DrawContext DrawContext, int mouseX, int mouseY, float delta) this.addDrawableChild(issuesButton); this.addSelectableChild(this.descriptionListWidget); this.addDrawableChild( - ButtonWidget.builder(Text.translatable("modmenu.modsFolder"), button -> Util.getOperatingSystem().open(new File(FabricLoader.getInstance().getGameDir().toFile(), "mods"))) + ButtonWidget.builder(Text.translatable("modmenu.modsFolder"), button -> Util.getOperatingSystem().open(FabricLoader.getInstance().getGameDir().resolve("mods").toUri())) .position(this.width / 2 - 154, this.height - 28) .size(150, 20) .narrationSupplier(Supplier::get) diff --git a/src/main/java/com/terraformersmc/modmenu/util/mod/quilt/QuiltMod.java b/src/main/java/com/terraformersmc/modmenu/util/mod/quilt/QuiltMod.java index d8fc3809f..3b057ee14 100644 --- a/src/main/java/com/terraformersmc/modmenu/util/mod/quilt/QuiltMod.java +++ b/src/main/java/com/terraformersmc/modmenu/util/mod/quilt/QuiltMod.java @@ -2,7 +2,6 @@ import com.google.common.collect.Lists; import com.google.common.hash.Hashing; -import com.google.common.io.Files; import com.terraformersmc.modmenu.util.ModrinthUtil; import com.terraformersmc.modmenu.util.mod.fabric.FabricMod; import org.jetbrains.annotations.NotNull; @@ -14,6 +13,7 @@ import java.io.IOException; import java.nio.file.FileSystems; +import java.nio.file.Files; import java.nio.file.Path; import java.util.Collections; import java.util.List; @@ -75,11 +75,11 @@ public QuiltMod(net.fabricmc.loader.api.ModContainer fabricModContainer, Set jars = paths.stream().filter(p -> p.toString().toLowerCase(Locale.ROOT).endsWith(".jar")).toList(); if (jars.size() == 1 && jars.get(0).getFileSystem() == FileSystems.getDefault()) { - var file = jars.get(0).toFile(); + var path = jars.get(0); - if (file.exists()) { + if (Files.exists(path)) { ModrinthUtil.LOGGER.debug("Found {} hash", getId()); - return Files.asByteSource(file).hash(Hashing.sha512()).toString(); + return com.google.common.io.Files.asByteSource(path.toFile()).hash(Hashing.sha512()).toString(); } } }