diff --git a/README.md b/README.md index 289332c..9ef9366 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,6 @@ A slim launcher for Minecraft in the development environment. -## Requirements (Delete on Release) - -- The ability to launch Minecraft paired with ForgeGradle 7. - - Down the road, we will want to be able to launch versions of Minecraft that use Java 8, old Bootstrap, and old FML. - ## Purpose SlimeLauncher is a standalone tool that allows users to launch Minecraft without needing to interface with the standard diff --git a/src/main/java/net/minecraftforge/launcher/FG2Hacks.java b/src/main/java/net/minecraftforge/launcher/FG2Hacks.java index 33a2cc6..7317311 100644 --- a/src/main/java/net/minecraftforge/launcher/FG2Hacks.java +++ b/src/main/java/net/minecraftforge/launcher/FG2Hacks.java @@ -25,7 +25,9 @@ import org.jetbrains.annotations.Nullable; -class FG2Hacks { +final class FG2Hacks { + private FG2Hacks() {} + /* ----------- COREMOD AND AT HACK --------- */ // coremod hack private static final String COREMOD_VAR = "fml.coreMods.load"; diff --git a/src/main/java/net/minecraftforge/launcher/LegacyDev.java b/src/main/java/net/minecraftforge/launcher/LegacyDev.java index 2b9ca75..6eb3237 100644 --- a/src/main/java/net/minecraftforge/launcher/LegacyDev.java +++ b/src/main/java/net/minecraftforge/launcher/LegacyDev.java @@ -27,7 +27,9 @@ /// This is the SlimeLauncher replacement for [LegacyDev](https://github.com/MinecraftForge/LegacyDev/). /// Which was written to Bridge 1.12.2 to FG3+ -class LegacyDev { +final class LegacyDev { + private LegacyDev() {} + static final Logger LOGGER = Main.LOGGER; static final String LEGACYDEV = "net.minecraftforge.legacydev."; static final String LEGACYDEV_CLIENT = LEGACYDEV + "MainClient"; diff --git a/src/main/java/net/minecraftforge/launcher/Main.java b/src/main/java/net/minecraftforge/launcher/Main.java index bed3719..8ca6a76 100644 --- a/src/main/java/net/minecraftforge/launcher/Main.java +++ b/src/main/java/net/minecraftforge/launcher/Main.java @@ -16,9 +16,7 @@ import java.io.File; import java.io.FileNotFoundException; -import java.io.FileOutputStream; import java.io.IOException; -import java.io.InputStream; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodType; @@ -26,8 +24,6 @@ import java.lang.reflect.Method; import java.util.Locale; import java.util.function.Supplier; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; public final class Main { static final Logger LOGGER = Logger.create(); @@ -82,8 +78,8 @@ private static Launcher run(String[] rawArgs) throws Throwable { .withRequiredArg().ofType(String.class).defaultsTo(Constants.RESOURCES_URL); // metadata - ArgumentAcceptingOptionSpec metadataZip0 = parser - .accepts("metadata", "The metadata.zip to use for runs") + ArgumentAcceptingOptionSpec metadataO = parser + .accepts("metadata", "The metadata directory to use for runs") .withRequiredArg().ofType(File.class); // main @@ -121,8 +117,7 @@ private static Launcher run(String[] rawArgs) throws Throwable { File cache = options.valueOf(cache0); File assets = options.valueOf(assetsO); String assetsRepo = options.valueOf(assetsRepo0); - // TODO [SlimeLauncher][Jonathing] CHANGE THIS TO DIR! It is already extracted by FG7! - File metadataZip = options.valueOf(metadataZip0); + File metadata = options.valueOf(metadataO); String mainClass = options.valueOf(mainClassO); File toObf = options.valueOf(toObfO); File toSrg = options.valueOf(toSrgO); @@ -143,11 +138,9 @@ else if (isUserDev) { // This is only used for 1.14->1.16, and only ever targete } MinecraftVersion versionJson; - try (ZipFile zip = new ZipFile(metadataZip)) { - versionJson = JsonData.minecraftVersion( - extract(zip, "minecraft/version.json", cache) - ); - } + File versionJsonFile = new File(metadata, "minecraft/version.json"); + if (versionJsonFile.isFile()) versionJson = JsonData.minecraftVersion(versionJsonFile); + else throw new FileNotFoundException("Missing minecraft/version.json in " + metadata.getAbsolutePath()); if (isClient) { DownloadAssets.checkAssets(assetsRepo, assets, versionJson, DISABLE_ASSETS); @@ -302,31 +295,4 @@ private SplitArgs(String[] args) { } } } - - private static File extract(ZipFile zip, String name, File cache) throws IOException { - File metadataDir = new File(cache, "metadata"); - if (!metadataDir.exists() && !metadataDir.mkdirs()) - throw new IllegalStateException("Failed to create directory: " + metadataDir.getAbsolutePath()); - - ZipEntry entry = zip.getEntry(name); - if (entry == null) - throw new FileNotFoundException("Missing " + name + " in " + zip.getName()); - - File output = new File(metadataDir, name); - File outputDir = output.getParentFile(); - if (!outputDir.exists() && !outputDir.mkdirs()) - throw new IllegalStateException("Failed to create directory: " + outputDir.getAbsolutePath()); - - // InputStream#transferTo(OutputStream) - try (FileOutputStream out = new FileOutputStream(output)) { - InputStream stream = zip.getInputStream(entry); - byte[] buf = new byte[8192]; - int length; - while ((length = stream.read(buf)) != -1) { - out.write(buf, 0, length); - } - } - - return output; - } }