This repository was archived by the owner on Nov 24, 2018. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +12
-20
lines changed
src/main/java/me/checkium/vhackapi Expand file tree Collapse file tree 2 files changed +12
-20
lines changed Original file line number Diff line number Diff line change @@ -40,13 +40,22 @@ public static String readJson(Reader rd) throws IOException {
40
40
public static JSONObject JSONRequest (String format , String data , String php ){
41
41
JSONObject json = null ;
42
42
String jsonText = StringRequest (format , data , php );
43
- if (jsonText .length () == 1 ) {
43
+ if ("" .equals (jsonText ))
44
+ {
45
+ throw new RuntimeException ("Old API URL" );
46
+ }
47
+ else if ("8" .equals (jsonText ))
48
+ {
49
+ throw new RuntimeException ("Wrong Password/User" );
50
+ }
51
+ else if (jsonText .length () == 1 ) {
44
52
return null ;
45
53
}
46
54
json = new JSONObject (jsonText );
47
55
return json ;
48
56
}
49
57
58
+ //it'll just do the request without any checks
50
59
public static String StringRequest (String format , String data , String php )
51
60
{
52
61
System .setProperty ("http.agent" , "Chrome" );
Original file line number Diff line number Diff line change 1
1
package me .checkium .vhackapi ;
2
2
3
- import java .io .BufferedReader ;
4
- import java .io .IOException ;
5
- import java .io .InputStream ;
6
- import java .io .InputStreamReader ;
7
- import java .net .URL ;
8
- import java .nio .charset .Charset ;
9
3
import java .util .concurrent .TimeUnit ;
10
4
11
5
import org .json .JSONObject ;
@@ -43,19 +37,8 @@ public String getStats(Stats stat) {
43
37
} catch (InterruptedException e1 ) {
44
38
e1 .printStackTrace ();
45
39
}
46
- JSONObject json = null ;
47
- InputStream is ;
48
- try {
49
- is = new URL (Utils .generateURL ("user::::pass::::uhash" , username + "::::" + password + "::::" + userHash , "vh_update.php" )).openStream ();
50
- BufferedReader rd = new BufferedReader (new InputStreamReader (is , Charset .forName ("UTF-8" )));
51
- String jsonText = Utils .readJson (rd );
52
- json = new JSONObject (jsonText );
53
- if (json .getString (stat .toString ()) == null ) {
54
- return null ;
55
- }
56
- } catch (IOException e ) {
57
- e .printStackTrace ();
58
- }
40
+ JSONObject json = Utils .JSONRequest ("user::::pass::::uhash" , username + "::::" + password + "::::" + userHash , "vh_update.php" );
41
+
59
42
return json .getString (stat .toString ());
60
43
}
61
44
You can’t perform that action at this time.
0 commit comments