Skip to content

Commit faf2e53

Browse files
committed
clean code
1 parent 2a8fcc7 commit faf2e53

2 files changed

Lines changed: 3 additions & 58 deletions

File tree

src/main/java/dev/architectury/loom/forge/config/InstallProfile.java

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/main/java/dev/architectury/loom/forge/dependency/PatchProvider.java

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -26,29 +26,21 @@
2626

2727
import java.io.File;
2828
import java.io.IOException;
29-
import java.io.Reader;
3029
import java.io.UncheckedIOException;
3130
import java.nio.file.Files;
3231
import java.nio.file.Path;
3332
import java.nio.file.StandardCopyOption;
3433

35-
import com.google.gson.Gson;
36-
import com.google.gson.JsonObject;
37-
import com.mojang.serialization.JsonOps;
38-
import dev.architectury.loom.forge.config.InstallProfile;
3934
import org.gradle.api.Project;
4035
import org.jetbrains.annotations.Nullable;
4136

4237
import net.fabricmc.loom.configuration.DependencyInfo;
4338
import net.fabricmc.loom.util.Constants;
4439
import net.fabricmc.loom.util.FileSystemUtil;
45-
import net.fabricmc.loom.util.ZipUtils;
4640

4741
public class PatchProvider extends DependencyProvider {
4842
private final Path projectCacheFolder;
4943
private File installerJar;
50-
private JsonObject json;
51-
private InstallProfile installProfile;
5244
private @Nullable Path clientPatches;
5345
private @Nullable Path serverPatches;
5446

@@ -61,27 +53,13 @@ public PatchProvider(Project project) {
6153
public void provide(DependencyInfo dependency) throws Exception {
6254
init();
6355

64-
installerJar = new File(getExtension().getForgeProvider().getGlobalCache(), "forge-installer.jar");
65-
Path installProfileJson = getExtension().getForgeProvider().getGlobalCache().toPath().resolve("forge-installProfile.json");
66-
67-
if (Files.notExists(installProfileJson) || refreshDeps()) {
68-
File resolved = dependency.resolveFile().orElseThrow(() -> new RuntimeException("Could not resolve Forge installer"));
69-
Files.copy(resolved.toPath(), installerJar.toPath(), StandardCopyOption.REPLACE_EXISTING);
70-
Files.write(installProfileJson, ZipUtils.unpack(resolved.toPath(), "install_profile.json"));
71-
}
72-
73-
try (Reader reader = Files.newBufferedReader(installProfileJson)) {
74-
json = new Gson().fromJson(reader, JsonObject.class);
75-
installProfile = InstallProfile.CODEC.parse(JsonOps.INSTANCE, json)
76-
.getOrThrow(false, msg -> getProject().getLogger().error("Couldn't read installer install profile, {}", msg));
77-
}
56+
installerJar = dependency.resolveFile().orElseThrow(() -> new RuntimeException("Could not resolve Forge installer"));
7857
}
7958

8059
public Path extractClientPatches() {
8160
if (clientPatches == null) {
8261
clientPatches = projectCacheFolder.resolve("patches-client.lzma");
83-
String binpatchName = installProfile.data().get("BINPATCH").client().replaceFirst("^/data/", "");
84-
extractPatches(clientPatches, binpatchName);
62+
extractPatches(clientPatches, "client.lzma");
8563
}
8664

8765
return clientPatches;
@@ -90,8 +68,7 @@ public Path extractClientPatches() {
9068
public Path extractServerPatches() {
9169
if (serverPatches == null) {
9270
serverPatches = projectCacheFolder.resolve("patches-server.lzma");
93-
String binpatchName = installProfile.data().get("BINPATCH").server().replaceFirst("^/data/", "");
94-
extractPatches(serverPatches, binpatchName);
71+
extractPatches(serverPatches, "server.lzma");
9572
}
9673

9774
return serverPatches;
@@ -122,12 +99,4 @@ private void init() {
12299
public String getTargetConfig() {
123100
return Constants.Configurations.FORGE_INSTALLER;
124101
}
125-
126-
public JsonObject getJson() {
127-
return json;
128-
}
129-
130-
public InstallProfile getInstallProfile() {
131-
return installProfile;
132-
}
133102
}

0 commit comments

Comments
 (0)