From 2bc7d4b7501a01174455b44c8c4e97384841eca7 Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 4 Jul 2018 20:49:42 +0500 Subject: [PATCH 1/3] add Minecraft 1.13 Structure Changes --- src/tagapi_3/API_Interface.java | 18 +++++++++++++----- src/tagapi_3/Local.java | 19 +++++++++++++++++++ src/tagapi_3/Network.java | 30 +++++++++++++++++++++++++++++- test/test_tagapi_3/Main.java | 5 +++-- 4 files changed, 64 insertions(+), 8 deletions(-) diff --git a/src/tagapi_3/API_Interface.java b/src/tagapi_3/API_Interface.java index 23431f5..839425a 100644 --- a/src/tagapi_3/API_Interface.java +++ b/src/tagapi_3/API_Interface.java @@ -873,13 +873,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); diff --git a/src/tagapi_3/Local.java b/src/tagapi_3/Local.java index 11d04cf..959988a 100644 --- a/src/tagapi_3/Local.java +++ b/src/tagapi_3/Local.java @@ -488,6 +488,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); diff --git a/src/tagapi_3/Network.java b/src/tagapi_3/Network.java index a8c489f..48391c4 100644 --- a/src/tagapi_3/Network.java +++ b/src/tagapi_3/Network.java @@ -6,6 +6,7 @@ package tagapi_3; import java.io.File; +import java.net.HttpURLConnection; import java.net.URL; import org.apache.commons.io.FileUtils; @@ -104,11 +105,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); @@ -120,7 +146,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) { diff --git a/test/test_tagapi_3/Main.java b/test/test_tagapi_3/Main.java index a0d5df4..d6c3ec4 100644 --- a/test/test_tagapi_3/Main.java +++ b/test/test_tagapi_3/Main.java @@ -38,11 +38,12 @@ public static void main(String[] args) { API.syncVersions(); String UsernameToUse = "Ammar_Ahmad"; - String VersionToUse = "17w43b"; + String VersionToUse = "1.13-pre3"; 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); From e7783c7e6b943aef23b404715efa268da2868a30 Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 4 Sep 2018 23:53:29 +0500 Subject: [PATCH 2/3] add structure change --- nbproject/project.properties | 20 ++++++++++++++++++++ src/tagapi_3/API_Interface.java | 27 +++++++++++++++++++++++---- src/tagapi_3/Local.java | 27 +++++++++++++++++++++++---- src/tagapi_3/Network.java | 27 +++++++++++++++++++++++---- src/tagapi_3/Utils.java | 27 +++++++++++++++++++++++---- test/test_tagapi_3/Main.java | 29 ++++++++++++++++++++++++----- 6 files changed, 136 insertions(+), 21 deletions(-) diff --git a/nbproject/project.properties b/nbproject/project.properties index 42bcda4..7fe68e3 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -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}:\ @@ -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} diff --git a/src/tagapi_3/API_Interface.java b/src/tagapi_3/API_Interface.java index 839425a..fd8bdf6 100644 --- a/src/tagapi_3/API_Interface.java +++ b/src/tagapi_3/API_Interface.java @@ -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; @@ -20,7 +39,7 @@ /** * - * @author ammar + * @author Ammar Ahmad */ public class API_Interface { diff --git a/src/tagapi_3/Local.java b/src/tagapi_3/Local.java index 959988a..b0e7253 100644 --- a/src/tagapi_3/Local.java +++ b/src/tagapi_3/Local.java @@ -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; @@ -31,7 +50,7 @@ /** * - * @author ammar + * @author Ammar Ahmad */ class Local { diff --git a/src/tagapi_3/Network.java b/src/tagapi_3/Network.java index 48391c4..f3aae4b 100644 --- a/src/tagapi_3/Network.java +++ b/src/tagapi_3/Network.java @@ -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.File; @@ -12,7 +31,7 @@ /** * - * @author ammar + * @author Ammar Ahmad */ class Network { diff --git a/src/tagapi_3/Utils.java b/src/tagapi_3/Utils.java index 2b556d2..dd41df1 100644 --- a/src/tagapi_3/Utils.java +++ b/src/tagapi_3/Utils.java @@ -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; @@ -43,7 +62,7 @@ import java.nio.file.Paths; /** * - * @author ammar + * @author Ammar Ahmad */ class Utils { diff --git a/test/test_tagapi_3/Main.java b/test/test_tagapi_3/Main.java index d6c3ec4..7fb0131 100644 --- a/test/test_tagapi_3/Main.java +++ b/test/test_tagapi_3/Main.java @@ -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 test_tagapi_3; import java.util.ArrayList; @@ -10,7 +29,7 @@ /** * - * @author ammar + * @author Ammar Ahmad */ public class Main { @@ -38,7 +57,7 @@ public static void main(String[] args) { API.syncVersions(); String UsernameToUse = "Ammar_Ahmad"; - String VersionToUse = "1.13-pre3"; + String VersionToUse = "1.13.1"; int MemoryToUse = 1024; API.setMemory(MemoryToUse); From 8e33eb0ad878631192f5ee9975661fff4b0fbaf4 Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 4 Sep 2018 23:55:54 +0500 Subject: [PATCH 3/3] add version updates --- api_meta | 2 +- src/tagapi_3/API_Interface.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api_meta b/api_meta index 00aa228..4f1367f 100644 --- a/api_meta +++ b/api_meta @@ -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 diff --git a/src/tagapi_3/API_Interface.java b/src/tagapi_3/API_Interface.java index fd8bdf6..0682c5b 100644 --- a/src/tagapi_3/API_Interface.java +++ b/src/tagapi_3/API_Interface.java @@ -44,7 +44,7 @@ public class API_Interface { public String getAPIVersion() { - return "v0.10-alpha"; + return "v0.11-alpha"; } public String getUpdateStatus() {