Skip to content

Commit

Permalink
Merge pull request #13 from ammarx/Minecraft_1.13_Structure_Changes
Browse files Browse the repository at this point in the history
Minecraft 1.13 structure changes
  • Loading branch information
ammarx authored Sep 4, 2018
2 parents 9d49bf1 + 8e33eb0 commit 8a02579
Show file tree
Hide file tree
Showing 7 changed files with 201 additions and 30 deletions.
2 changes: 1 addition & 1 deletion api_meta
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.10-alpha:v0.9-alpha:v0.8-alpha:v0.7-alpha:v0.6-alpha:v0.5-alpha:v0.4-alpha:v0.3-alpha:v0.2-alpha:v0.1-alpha
v0.11-alpha:v0.10-alpha:v0.9-alpha:v0.8-alpha:v0.7-alpha:v0.6-alpha:v0.5-alpha:v0.4-alpha:v0.3-alpha:v0.2-alpha:v0.1-alpha
20 changes: 20 additions & 0 deletions nbproject/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ file.reference.json-simple-1.1.1.jar=lib/json-simple-1.1.1.jar
file.reference.MoonLakeNBT-1.0.1.jar=lib/MoonLakeNBT-1.0.1.jar
file.reference.zt-zip-1.11.jar=lib/zt-zip-1.11.jar
includes=**
jar.archive.disabled=${jnlp.enabled}
jar.compress=false
jar.index=${jnlp.enabled}
javac.classpath=\
${file.reference.HEX_MOD.jar}:\
${file.reference.MoonLakeNBT-1.0.1.jar}:\
Expand Down Expand Up @@ -68,11 +70,29 @@ javadoc.splitindex=true
javadoc.use=true
javadoc.version=false
javadoc.windowtitle=
jnlp.codebase.type=no.codebase
jnlp.descriptor=application
jnlp.enabled=false
jnlp.mixed.code=default
jnlp.offline-allowed=false
jnlp.signed=false
jnlp.signing=
jnlp.signing.alias=
jnlp.signing.keystore=
main.class=tagapi_3.TagAPI_3
# Optional override of default Application-Library-Allowable-Codebase attribute identifying the locations where your signed RIA is expected to be found.
manifest.custom.application.library.allowable.codebase=
# Optional override of default Caller-Allowable-Codebase attribute identifying the domains from which JavaScript code can make calls to your RIA without security prompts.
manifest.custom.caller.allowable.codebase=
# Optional override of default Codebase manifest attribute, use to prevent RIAs from being repurposed
manifest.custom.codebase=
# Optional override of default Permissions manifest attribute (supported values: sandbox, all-permissions)
manifest.custom.permissions=
manifest.file=manifest.mf
meta.inf.dir=${src.dir}/META-INF
mkdist.disabled=false
platform.active=default_platform
project.license=mit
run.classpath=\
${javac.classpath}:\
${build.classes.dir}
Expand Down
47 changes: 37 additions & 10 deletions src/tagapi_3/API_Interface.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
* MIT License
* Copyright (c) 2018 Ammar Ahmad
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package tagapi_3;

import com.minecraft.moonlake.nbt.NBTTagCompound;
Expand All @@ -20,12 +39,12 @@

/**
*
* @author ammar
* @author Ammar Ahmad
*/
public class API_Interface {

public String getAPIVersion() {
return "v0.10-alpha";
return "v0.11-alpha";
}

public String getUpdateStatus() {
Expand Down Expand Up @@ -873,13 +892,21 @@ public void downloadMinecraft(String VersionToUse, Boolean ForceDownload) {

this.setDownloadLogs("DOWNLOADING MINECRAFT JAR " + VersionToUse);
if (MOD_jar == null) {
network.downloadMinecraftJar(OperatingSystemToUse, VersionToUse, ForceDownload);


int downloadMinecraftJarStatus = network.downloadMinecraftJar(OperatingSystemToUse, VersionToUse, ForceDownload) ;
if (downloadMinecraftJarStatus == 1)
{
network.downloadMinecraftJar_fallBack_v1(OperatingSystemToUse, local.readJson_downloads_client_url(utils.getMineCraft_Version_Json(OperatingSystemToUse, VersionToUse)), VersionToUse, ForceDownload);
}
} else {
network.downloadMinecraftJar(OperatingSystemToUse, MOD_jar, ForceDownload);

//local.readJson_downloads_client_url(utils.getMineCraft_Version_Json(OperatingSystemToUse, VersionToUse));
int downloadMinecraftJarStatus = network.downloadMinecraftJar(OperatingSystemToUse, MOD_jar, ForceDownload);
if (downloadMinecraftJarStatus == 1)
{
network.downloadMinecraftJar_fallBack_v1(OperatingSystemToUse, local.readJson_downloads_client_url(utils.getMineCraft_Version_Json(OperatingSystemToUse, VersionToUse)), MOD_jar, ForceDownload);
}
}

//would have tp edit this line as we also need natives paths!
this.setDownloadLogs("Getting NATIVES URL");
local.readJson_libraries_downloads_classifiers_natives_X(utils.getMineCraft_Versions_X_X_json(OperatingSystemToUse, VersionToUse), OperatingSystemToUse);
Expand Down
46 changes: 42 additions & 4 deletions src/tagapi_3/Local.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
* MIT License
* Copyright (c) 2018 Ammar Ahmad
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package tagapi_3;

import java.io.BufferedWriter;
Expand Down Expand Up @@ -31,7 +50,7 @@

/**
*
* @author ammar
* @author Ammar Ahmad
*/
class Local {

Expand Down Expand Up @@ -488,6 +507,25 @@ public void readJson_objects_KEY_hash(String path) {

}

public String readJson_downloads_client_url(String path) {
try {

FileReader reader = new FileReader(path);
JSONParser jsonParser = new JSONParser();
JSONObject jsonObject = (JSONObject) jsonParser.parse(reader);
JSONObject downloads = (JSONObject) jsonObject.get("downloads");
JSONObject client = (JSONObject) downloads.get("client");
return ((String) (client.get("url")));

} catch (FileNotFoundException exception) {
System.out.println(exception);
} catch (IOException | ParseException ex) {
System.out.println(ex);
}
return "N/A";
}


public String readJson_assetIndex_url(String path) {
try {
FileReader reader = new FileReader(path);
Expand Down
57 changes: 52 additions & 5 deletions src/tagapi_3/Network.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,37 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
* MIT License
* Copyright (c) 2018 Ammar Ahmad
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package tagapi_3;

import java.io.File;
import java.net.HttpURLConnection;
import java.net.URL;
import org.apache.commons.io.FileUtils;

/**
*
* @author ammar
* @author Ammar Ahmad
*/
class Network {

Expand Down Expand Up @@ -104,11 +124,36 @@ public void downloadLaunchermeta(String OS, String _url, String version, Boolean
System.out.print(e);
}
}

public void downloadMinecraftJar_fallBack_v1(String OS, String _url, String version, Boolean ForceDownload)
{
try {
Utils utils = new Utils();
URL url = new URL(_url);
File file = new File(utils.getMineCraft_Versions_X_X_jar_Location(OS, version));
if (ForceDownload == true) {
FileUtils.copyURLToFile(url, file);
} else if (file.exists()) {
//do not download..
System.out.println("File Exists! - Skipping download");
} else {
FileUtils.copyURLToFile(url, file);
}
} catch (Exception e) {
System.out.print(e);
}
}

public void downloadMinecraftJar(String OS, String version, Boolean ForceDownload) {
public int downloadMinecraftJar(String OS, String version, Boolean ForceDownload) {
try {
Utils utils = new Utils();
URL url = new URL(https_s3_amazonaws_com_Minecraft_Download_versions + "/" + version + "/" + version + ".jar");
HttpURLConnection httpCon = (HttpURLConnection) url.openConnection();
if (httpCon.getResponseCode() == 403 || httpCon.getResponseCode() == 404)
{
//use client.jar scheme
return 1;
}
File file = new File(utils.getMineCraft_Versions_X_X_jar_Location(OS, version));
if (ForceDownload == true) {
FileUtils.copyURLToFile(url, file);
Expand All @@ -120,7 +165,9 @@ public void downloadMinecraftJar(String OS, String version, Boolean ForceDownloa
}
} catch (Exception e) {
System.out.print(e);
return 1;
}
return 0;
}

public void downloadVersionManifest(String _filepath) {
Expand Down
27 changes: 23 additions & 4 deletions src/tagapi_3/Utils.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
* MIT License
* Copyright (c) 2018 Ammar Ahmad
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package tagapi_3;

import java.io.BufferedWriter;
Expand Down Expand Up @@ -43,7 +62,7 @@
import java.nio.file.Paths;
/**
*
* @author ammar
* @author Ammar Ahmad
*/
class Utils {

Expand Down
32 changes: 26 additions & 6 deletions test/test_tagapi_3/Main.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,35 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
* MIT License
* Copyright (c) 2018 Ammar Ahmad
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package test_tagapi_3;

import java.util.ArrayList;
import java.util.List;

/**
*
* @author ammar
* @author Ammar Ahmad
*/
public class Main {

Expand Down Expand Up @@ -38,11 +57,12 @@ public static void main(String[] args) {
API.syncVersions();

String UsernameToUse = "Ammar_Ahmad";
String VersionToUse = "17w43b";
String VersionToUse = "1.13.1";
int MemoryToUse = 1024;
API.setMemory(MemoryToUse);

//API.downloadVersionManifest(); //disabled
//API.downloadMinecraft(VersionToUse, false); //force download flag //disabled
API.downloadMinecraft(VersionToUse, false); //force download flag //disabled
//API.injectNetty();
API.runMinecraft(UsernameToUse, VersionToUse, false, false);

Expand Down

0 comments on commit 8a02579

Please sign in to comment.