Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update mod to Minecraft snapshot 23w44a #670

Merged
merged 1 commit into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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()) {
Expand Down Expand Up @@ -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();
}
Expand All @@ -88,7 +90,7 @@ private static void load() {
@SuppressWarnings("unchecked")
public static void save() {
ModMenu.clearModCountCache();
prepareConfigFile();
prepareConfigPath();

JsonObject config = new JsonObject();

Expand Down Expand Up @@ -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");
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/com/terraformersmc/modmenu/gui/ModsScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -75,11 +75,11 @@ public QuiltMod(net.fabricmc.loader.api.ModContainer fabricModContainer, Set<Str
List<Path> 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();
}
}
}
Expand Down