package com.dsdev.assets;

import com.google.gson.*;
import java.io.*;
import java.net.URL;
import java.nio.ByteBuffer;
import java.nio.channels.*;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Paths;

/**
 * This class contains all of the tools required to build and maintain a copy of
 * the Minecraft assets.
 *
 * @author Nathan2055
 */
public class AssetBuilder {

    /**
     * A File object representing the assets definition file from Mojang.
     */
    private File defFile;

    /**
     * This method builds a fresh copy of the Minecraft assets in the provided
     * directory. If the directory already exists, it is deleted.
     *
     * @param directory A String representing the directory where the assets
     * should be created.
     * @throws java.io.IOException Of course. :P
     */
    public void buildAssets(String directory) throws IOException {
        // Let's start by setting up the folders we are gonna need.
        File buffer = new File(directory + "/legacy");
        buffer.mkdirs();

        // Now let's fetch the version definition file from Mojang.
        defFile = File.createTempFile("assets", ".json");
        URL defWeb = new URL("https://s3.amazonaws.com/Minecraft.Download/indexes/legacy.json");
        ReadableByteChannel rbc = Channels.newChannel(defWeb.openStream());
        FileOutputStream fos = new FileOutputStream(defFile);
        fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);

        // And now we parse...
        String defPathString = defFile.getAbsolutePath();
        byte[] encoded = Files.readAllBytes(Paths.get(defPathString));
        String defString = Charset.defaultCharset().decode(ByteBuffer.wrap(encoded)).toString();
        BufferedReader br = new BufferedReader(new FileReader(defFile));
        Gson gson = new GsonBuilder().create();
        //DataObject obj = gson.fromJson(br, DataObject);
    }
}

@@ -229,16 +229,56 @@
 e.Paths;
+%0Aimport org.apache.commons.io.FileUtils;
 %0A%0A/**%0A *
@@ -443,125 +443,8 @@
  %7B%0A%0A
-    /**%0A     * A File object representing the assets definition file from Mojang.%0A     */%0A    private File defFile;%0A%0A
     
@@ -1051,16 +1051,21 @@
         
+File 
 defFile 
@@ -1454,20 +1454,16 @@
 ring def
-Path
 String =
@@ -1467,381 +1467,83 @@
 g = 
-def
 File
-.getAbsolutePath();%0A        byte%5B%5D encoded = F
+Ut
 il
-e
 s.read
-AllBytes(Paths.get(defPathString));%0A        String defString = Charset.defaultCharset().decode(ByteBuffer.wrap(encoded)).toString();%0A        BufferedReader br = new BufferedReader(new FileReader(defFile));%0A        Gson gson = new GsonBuilder().create();%0A        //DataObject obj = gson.fromJson(br, DataObject);
+FileToString(defFile);%0A        //JSON parsing code goes here.
 %0A   

Remove the broken code Signed-off-by:Nathan2055 <spychicken2055@gmail.com>