@@ -72,9 +72,11 @@ public void doTask() throws Exception {
7272 VersionsParser .setCurrentVersion (chosenVersion );
7373
7474 long startTime = System .currentTimeMillis ();
75- MCP .logger .info (" Downloading mappings" );
76- FileUtil .downloadFile (VersionsParser .downloadVersion (), Paths .get (MCPConfig .CONF , "conf.zip" ));
77- FileUtil .unzip (Paths .get (MCPConfig .CONF , "conf.zip" ), Paths .get (MCPConfig .CONF ), true );
75+ if (Files .notExists (Paths .get ("versions.json" ))) {
76+ MCP .logger .info (" Downloading mappings" );
77+ FileUtil .downloadFile (VersionsParser .downloadVersion (), Paths .get (MCPConfig .CONF , "conf.zip" ));
78+ FileUtil .unzip (Paths .get (MCPConfig .CONF , "conf.zip" ), Paths .get (MCPConfig .CONF ), true );
79+ }
7880
7981 MCP .logger .info (" Setting up workspace" );
8082 FileUtil .deleteDirectoryIfExists (Paths .get ("workspace" ));
@@ -95,9 +97,17 @@ public void doTask() throws Exception {
9597 startTime = System .currentTimeMillis ();
9698 MCP .logger .info (" Downloading Minecraft " + (side == CLIENT ? "client" : "server" ) + "..." );
9799 String url = VersionsParser .getDownloadURL (side );
98- // TODO Classic server zips
99- Path pathOut = Paths .get (side == CLIENT ? MCPConfig .CLIENT : MCPConfig .SERVER );
100- FileUtil .downloadFile (new URL (url ), pathOut );
100+ String out = side == CLIENT ? MCPConfig .CLIENT : MCPConfig .SERVER ;
101+ Path pathOut = Paths .get (out );
102+ if (url .endsWith (".jar" )) {
103+ FileUtil .downloadFile (new URL (url ), pathOut );
104+ }
105+ else {
106+ Path zip = Paths .get (out .replace (".jar" , ".zip" ));
107+ FileUtil .downloadFile (new URL (url ), zip );
108+ FileUtil .copyFileFromAZip (zip , "minecraft-server.jar" , pathOut );
109+ Files .deleteIfExists (zip );
110+ }
101111 MCP .logger .info (" Done in " + Util .time (System .currentTimeMillis () - startTime ));
102112 }
103113 }
@@ -117,7 +127,9 @@ public void doTask() throws Exception {
117127
118128 private void setWorkspace () throws Exception {
119129 String [] projects = { "Client" , "Server" };
120- for (String project : projects ) {
130+ for (int i2 = 0 ; i2 < projects .length ; i2 ++) {
131+ String project = projects [i2 ];
132+ String startclass = VersionsParser .hasServer () && VersionsParser .getServerVersion ().startsWith ("c" ) ? "com.mojang.minecraft.server.MinecraftServer" : "net.minecraft.server.MinecraftServer" ;
121133 Path [] filetoRead = new Path [] {
122134 Paths .get ("workspace" , ".metadata" , ".plugins" , "org.eclipse.debug.core" , ".launches" , project + ".launch" ),
123135 Paths .get ("workspace" , project , ".idea" , "workspace.xml" ),
@@ -126,18 +138,27 @@ private void setWorkspace() throws Exception {
126138 for (int j = 0 ; j < filetoRead .length ; j ++) {
127139 if (Files .exists (filetoRead [j ])) {
128140 List <String > lines = Files .readAllLines (filetoRead [j ]);
129- String replace = "-Dhttp.proxyPort=%s" ;
130141 for (int i = 0 ; i < lines .size (); i ++) {
131142 switch (j ) {
132143 case 0 :
144+ if (i2 == SERVER ) {
145+ String [] replace = new String [] {"value=\" /Server/src/%s.java\" " , "key=\" org.eclipse.jdt.launching.MAIN_TYPE\" value=\" %s\" " };
146+ lines .set (i , lines .get (i ).replace (replace [0 ], String .format (replace [0 ], startclass .replace ("." , "/" ))));
147+ lines .set (i , lines .get (i ).replace (replace [1 ], String .format (replace [1 ], startclass )));
148+ }
133149 case 1 :
150+ String replace = "-Dhttp.proxyPort=%s" ;
134151 lines .set (i , lines .get (i ).replace (replace , String .format (replace , VersionsParser .getProxyPort ())));
152+ if (i2 == SERVER ) {
153+ String replace2 = "name=\" MAIN_CLASS_NAME\" value=\" %s\" " ;
154+ lines .set (i , lines .get (i ).replace (replace2 , String .format (replace2 , startclass )));
155+ }
135156 break ;
136157 case 2 :
137158 lines .set (i , lines .get (i ).replace ("$MCP_LOC$" , Paths .get (System .getProperty ("user.dir" )).toAbsolutePath ().toString ().replace ("\\ " , "/" )));
138159 break ;
139160 case 3 :
140- if (!VersionsParser .hasServer () && lines .get (i ).contains ("path="Server"" )) {
161+ if (i2 == SERVER && !VersionsParser .hasServer () && lines .get (i ).contains ("path="Server"" )) {
141162 lines .remove (i );
142163 }
143164 break ;
0 commit comments