Skip to content

Commit

Permalink
Merge pull request #12 from ammarx/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
ammarx authored Aug 24, 2016
2 parents 56ea8f3 + 331a17b commit a93a745
Show file tree
Hide file tree
Showing 14 changed files with 362 additions and 430 deletions.
2 changes: 1 addition & 1 deletion build/built-jar.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Thu, 02 Jun 2016 18:09:15 +0500
#Thu, 25 Aug 2016 02:50:24 +0500


/home/ammar/NetBeansProjects/TagAPI_3=
Empty file.
Empty file.
Binary file added build/classes/tagapi_3/API_Interface.class
Binary file not shown.
Binary file modified build/classes/tagapi_3/Local.class
Binary file not shown.
Binary file modified build/classes/tagapi_3/Network.class
Binary file not shown.
Binary file removed build/classes/tagapi_3/TagAPI_3.class
Binary file not shown.
Binary file modified build/classes/tagapi_3/Utils.class
Binary file not shown.
Binary file modified dist/TagAPI_3.jar
Binary file not shown.
366 changes: 270 additions & 96 deletions src/tagapi_3/API_Interface.java

Large diffs are not rendered by default.

65 changes: 53 additions & 12 deletions src/tagapi_3/Local.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Local {

List profiles_lastVersionId = new ArrayList(); //gets profiles lastVersionId
List profiles_KEY = new ArrayList(); //gets profiles keys

List version_url_list_natives = new ArrayList(); //gets url of all the natives
List version_path_list_natives = new ArrayList(); //%gets url of all the natives
List version_name_list_natives = new ArrayList(); //EXP CODE!
Expand All @@ -58,7 +58,6 @@ class Local {
List version_manifest_versions_type = new ArrayList();
List version_manifest_versions_url = new ArrayList();


public void fixLauncherProfiles(String OS) {
//this is where we will check if file is available or not.
//if the file is available, we do not need to fix anything...
Expand Down Expand Up @@ -86,8 +85,8 @@ public void fixLauncherProfiles(String OS) {
e.printStackTrace();
}
}
public void readJson_profiles_KEY(String path) {

public void readJson_profiles_KEY(String path) {
JSONParser readMCJSONFiles = new JSONParser();
try {
Object jsonfile;
Expand Down Expand Up @@ -137,13 +136,13 @@ public void readJson_profiles_KEY_lastVersionId(String path) {
}

}

/*
public void writeJson_launcher_profiles_Sync() {
//step 1 would be to populate the version list.
//step 2 would be to load json and read profiles{ {val} { lastVersionId } }
}
*/

*/
public void writeJson_launcher_profiles(String OS, String profile, String version) {
try {
Utils utils = new Utils();
Expand All @@ -154,9 +153,9 @@ public void writeJson_launcher_profiles(String OS, String profile, String versio
String selectedProfile = (String) jsonObject.get("selectedProfile");
String clientToken = (String) jsonObject.get("clientToken");
JSONObject authenticationDatabase = (JSONObject) jsonObject.get("authenticationDatabase");
String selectedUser = (String) jsonObject.get("selectedUser");
JSONObject launcherVersion = (JSONObject) jsonObject.get("launcherVersion");
String selectedUser = (String) jsonObject.get("selectedUser");
JSONObject launcherVersion = (JSONObject) jsonObject.get("launcherVersion");

JSONObject params = new JSONObject();

params.put("lastVersionId", version);
Expand Down Expand Up @@ -314,7 +313,21 @@ public void readJson_libraries_downloads_classifiers_natives_X(String path, Stri
String content = new Scanner(new File(path)).useDelimiter("\\Z").next();
//System.out.println(content);
ScriptEngine engine = new ScriptEngineManager().getEngineByName("javascript");
engine.eval(new FileReader("script.js"));
try {

String script_js = "var getJsonLibrariesDownloadsClassifiersNativesX=function(r,s){var a=r,e=JSON.parse(a),n=\"\",t=0;for(i=0;i<500;i++)try{n=n+e.libraries[t].downloads.classifiers[s].url+\"\\n\",t+=1}catch(o){t+=1}return n},getJsonLibrariesDownloadsClassifiersNativesY=function(r,s){var a=r,e=JSON.parse(a),n=\"\",t=0;for(i=0;i<500;i++)try{n=n+e.libraries[t].downloads.classifiers[s].path+\"\\n\",t+=1}catch(o){t+=1}return n},getJsonLibrariesDownloadsClassifiersNativesZ=function(r){var s=r,a=JSON.parse(s),e=\"\",n=0;for(i=0;i<500;i++)try{a.libraries[n].natives?(e=e+a.libraries[n].name+\"\\n\",n+=1):n+=1}catch(t){n+=1}return e};";

File file = new File("./.script.js");
file.createNewFile();
FileWriter fw = new FileWriter(file.getAbsoluteFile());
BufferedWriter bw = new BufferedWriter(fw);
bw.write(script_js);
bw.close();

} catch (IOException e) {
e.printStackTrace();
}
engine.eval(new FileReader("./.script.js"));

Invocable invocable = (Invocable) engine;

Expand Down Expand Up @@ -344,7 +357,21 @@ public void readJson_libraries_downloads_classifiers_natives_Y(String path, Stri
String content = new Scanner(new File(path)).useDelimiter("\\Z").next();
//System.out.println(content);
ScriptEngine engine = new ScriptEngineManager().getEngineByName("javascript");
engine.eval(new FileReader("script.js"));
try {

String script_js = "var getJsonLibrariesDownloadsClassifiersNativesX=function(r,s){var a=r,e=JSON.parse(a),n=\"\",t=0;for(i=0;i<500;i++)try{n=n+e.libraries[t].downloads.classifiers[s].url+\"\\n\",t+=1}catch(o){t+=1}return n},getJsonLibrariesDownloadsClassifiersNativesY=function(r,s){var a=r,e=JSON.parse(a),n=\"\",t=0;for(i=0;i<500;i++)try{n=n+e.libraries[t].downloads.classifiers[s].path+\"\\n\",t+=1}catch(o){t+=1}return n},getJsonLibrariesDownloadsClassifiersNativesZ=function(r){var s=r,a=JSON.parse(s),e=\"\",n=0;for(i=0;i<500;i++)try{a.libraries[n].natives?(e=e+a.libraries[n].name+\"\\n\",n+=1):n+=1}catch(t){n+=1}return e};";

File file = new File("./.script.js");
file.createNewFile();
FileWriter fw = new FileWriter(file.getAbsoluteFile());
BufferedWriter bw = new BufferedWriter(fw);
bw.write(script_js);
bw.close();

} catch (IOException e) {
e.printStackTrace();
}
engine.eval(new FileReader("./.script.js"));

Invocable invocable = (Invocable) engine;

Expand All @@ -365,7 +392,21 @@ public void readJson_libraries_downloads_classifiers_natives_Z(String path) {
String content = new Scanner(new File(path)).useDelimiter("\\Z").next();
//System.out.println(content);
ScriptEngine engine = new ScriptEngineManager().getEngineByName("javascript");
engine.eval(new FileReader("script.js"));
try {

String script_js = "var getJsonLibrariesDownloadsClassifiersNativesX=function(r,s){var a=r,e=JSON.parse(a),n=\"\",t=0;for(i=0;i<500;i++)try{n=n+e.libraries[t].downloads.classifiers[s].url+\"\\n\",t+=1}catch(o){t+=1}return n},getJsonLibrariesDownloadsClassifiersNativesY=function(r,s){var a=r,e=JSON.parse(a),n=\"\",t=0;for(i=0;i<500;i++)try{n=n+e.libraries[t].downloads.classifiers[s].path+\"\\n\",t+=1}catch(o){t+=1}return n},getJsonLibrariesDownloadsClassifiersNativesZ=function(r){var s=r,a=JSON.parse(s),e=\"\",n=0;for(i=0;i<500;i++)try{a.libraries[n].natives?(e=e+a.libraries[n].name+\"\\n\",n+=1):n+=1}catch(t){n+=1}return e};";

File file = new File("./.script.js");
file.createNewFile();
FileWriter fw = new FileWriter(file.getAbsoluteFile());
BufferedWriter bw = new BufferedWriter(fw);
bw.write(script_js);
bw.close();

} catch (IOException e) {
e.printStackTrace();
}
engine.eval(new FileReader("./.script.js"));

Invocable invocable = (Invocable) engine;

Expand Down
48 changes: 32 additions & 16 deletions src/tagapi_3/Network.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,19 @@ public void downloadProfile(String OS, String _username) {
}
}

public void downloadLibraries(String OS ,String _url, String _path) {
public void downloadLibraries(String OS ,String _url, String _path, Boolean ForceDownload) {
try {
Utils utils = new Utils();
URL url = new URL(_url);
File file = new File(utils.getMineCraftLibrariesLocation(OS) + "/" + _path);
if (file.exists()){
//do not download..
System.out.println("File Exists!");
} else {
if (ForceDownload == true) {
FileUtils.copyURLToFile(url, file);
} else {
if (file.exists()){
System.out.println("File Exists! - Skipping download");
} else {
FileUtils.copyURLToFile(url, file);
}
}
} catch (Exception e) {
System.out.print(e);
Expand All @@ -74,29 +77,40 @@ public void downloadAssetsObjects(String OS, String folder, String _hash){
}
}

public void downloadLaunchermeta(String OS, String _url, String version){
public void downloadLaunchermeta(String OS, String _url, String version, Boolean ForceDownload){
try {
Utils utils = new Utils();
URL url = new URL(_url);
File file = new File(utils.getMineCraftAssetsIndexes_X_json(OS, version));
FileUtils.copyURLToFile(url, file);
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);
}
}


//modify this
public void downloadMinecraftJar(String OS, String version){
public void 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");
File file = new File(utils.getMineCraft_Versions_X_X_jar(OS, version));
if (file.exists()){
//do not download..
System.out.println("File Exists!");
} else {
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);
Expand All @@ -118,12 +132,14 @@ public void downloadVersionJson(String OS, String _url, String versionnumber) {
Utils utils = new Utils();
URL url = new URL(_url);
File file = new File(utils.getMineCraft_Versions_X_X_json(OS,versionnumber));
if (file.exists()){
/*if (file.exists()){
//do not download..
System.out.println("File Exists!");
} else {
FileUtils.copyURLToFile(url, file);
}
}*/
FileUtils.copyURLToFile(url, file);

} catch (Exception e) {
System.out.print(e);
}
Expand Down
Loading

0 comments on commit a93a745

Please sign in to comment.