From d05cffa24baf0739968150d0b5262b66ba69c5de Mon Sep 17 00:00:00 2001 From: LostLuma Date: Tue, 16 Apr 2024 22:50:49 +0200 Subject: [PATCH] Fix user agent stripping not working --- .../com/terraformersmc/modmenu/util/UpdateCheckerUtil.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/terraformersmc/modmenu/util/UpdateCheckerUtil.java b/src/main/java/com/terraformersmc/modmenu/util/UpdateCheckerUtil.java index 509c2060..7bf5e9ca 100644 --- a/src/main/java/com/terraformersmc/modmenu/util/UpdateCheckerUtil.java +++ b/src/main/java/com/terraformersmc/modmenu/util/UpdateCheckerUtil.java @@ -81,9 +81,9 @@ public static void checkForModrinthUpdates() { List loaders = ModMenu.runningQuilt ? List.of("fabric", "quilt") : List.of("fabric"); String mcVer = SharedConstants.getGameVersion().getName(); - String[] splitVersion = FabricLoader.getInstance().getModContainer(ModMenu.MOD_ID) - .get().getMetadata().getVersion().getFriendlyString().split("\\+", 1); // Strip build metadata for privacy - final var modMenuVersion = splitVersion.length > 1 ? splitVersion[1] : splitVersion[0]; + String version = FabricLoader.getInstance().getModContainer(ModMenu.MOD_ID) + .get().getMetadata().getVersion().getFriendlyString(); + final var modMenuVersion = version.split("\\+", 2)[0]; // Strip build metadata for privacy final var userAgent = "%s/%s (%s/%s%s)".formatted(ModMenu.GITHUB_REF, modMenuVersion, mcVer, primaryLoader, environment); String body = ModMenu.GSON_MINIFIED.toJson(new LatestVersionsFromHashesBody(modHashes.keySet(), loaders, mcVer)); LOGGER.debug("User agent: " + userAgent);