1
1
package org .mcphackers .mcp .tools .versions ;
2
2
3
3
import java .io .IOException ;
4
- import java .net .URL ;
5
4
import java .nio .file .Files ;
6
5
import java .nio .file .Path ;
7
6
import java .util .ArrayList ;
8
7
import java .util .List ;
9
- import java .util .Map .Entry ;
10
8
11
- import org .json .JSONObject ;
12
9
import org .mcphackers .mcp .DownloadListener ;
13
10
import org .mcphackers .mcp .MCP ;
14
11
import org .mcphackers .mcp .MCPPaths ;
17
14
import org .mcphackers .mcp .tools .Util ;
18
15
import org .mcphackers .mcp .tools .versions .json .Artifact ;
19
16
import org .mcphackers .mcp .tools .versions .json .AssetIndex ;
20
- import org .mcphackers .mcp .tools .versions .json .AssetIndex .Asset ;
21
17
import org .mcphackers .mcp .tools .versions .json .DependDownload ;
22
18
import org .mcphackers .mcp .tools .versions .json .Download ;
23
19
import org .mcphackers .mcp .tools .versions .json .Rule ;
@@ -39,7 +35,6 @@ public DownloadEntry(Download dl, Path filePath, boolean verify) {
39
35
40
36
protected List <DownloadEntry > downloadQueue = new ArrayList <>();
41
37
protected AssetIndex assets ;
42
- private Path gameDir ;
43
38
public int totalSize ;
44
39
public List <DownloadEntry > natives = new ArrayList <>();
45
40
@@ -48,7 +43,6 @@ public DownloadData(MCP mcp, Version version) {
48
43
}
49
44
50
45
public DownloadData (Path libraries , Path gameDir , Path client , Path server , Version version ) {
51
- this .gameDir = gameDir ;
52
46
if (version .downloads .client != null && client != null ) {
53
47
queueDownload (version .downloads .client , client , true ); // TODO may want to make verify flag togglable
54
48
}
@@ -73,29 +67,6 @@ public DownloadData(Path libraries, Path gameDir, Path client, Path server, Vers
73
67
}
74
68
}
75
69
}
76
- try {
77
- Path assetIndex = gameDir .resolve ("assets/indexes/" + version .assets + ".json" );
78
- String assetIndexString ;
79
- if (!Files .exists (assetIndex ) || !version .assetIndex .sha1 .equals (Util .getSHA1 (assetIndex ))) {
80
- assetIndexString = new String (Util .readAllBytes (new URL (version .assetIndex .url ).openStream ()));
81
- Files .write (assetIndex , assetIndexString .getBytes ());
82
- }
83
- else {
84
- assetIndexString = new String (Files .readAllBytes (assetIndex ));
85
- }
86
- setAssets (AssetIndex .from (new JSONObject (assetIndexString )));
87
- }
88
- catch (IOException ignored ) {}
89
- }
90
-
91
- public void setAssets (AssetIndex assets ) {
92
- if (this .assets != null ) {
93
- return ;
94
- }
95
- this .assets = assets ;
96
- for (Entry <String , Asset > entry : assets .objects .entrySet ()) {
97
- totalSize += entry .getValue ().size ();
98
- }
99
70
}
100
71
101
72
public DownloadEntry queueDownload (Download dl , Path path , boolean verify ) {
@@ -119,20 +90,6 @@ public void performDownload(DownloadListener listener) throws IOException {
119
90
FileUtil .downloadFile (dlObj .url , file );
120
91
}
121
92
}
122
- if (assets != null ) {
123
- for (Entry <String , Asset > entry : assets .objects .entrySet ()) {
124
- Asset asset = entry .getValue ();
125
- String hash = asset .hash .substring (0 , 2 ) + "/" + asset .hash ;
126
- String filename = assets .map_to_resources ? "resources/" + entry .getKey () : "assets/objects/" + hash ;
127
- Path file = gameDir .resolve (filename );
128
- listener .notify (asset , totalSize );
129
- if (!Files .exists (file )) {
130
- Path parent = file .getParent ();
131
- if (parent != null ) Files .createDirectories (parent );
132
- FileUtil .downloadFile ("http://resources.download.minecraft.net/" + hash , file );
133
- }
134
- }
135
- }
136
93
}
137
94
138
95
public static List <String > getLibraries (Version version ) {
0 commit comments