@@ -17,18 +17,25 @@ public static void main(String[] args) throws IOException {
1717 List <String > namesJson = new ArrayList <>();
1818 List <String > to_be_updated_fn = new ArrayList <>();
1919 List <String > to_be_updated_n = new ArrayList <>();
20+ List <String > to_be_updated_fn_p = new ArrayList <>();
21+ List <String > to_be_updated_n_p = new ArrayList <>();
2022
2123 int errors = 0 ;
2224
23- PrintStream out = new PrintStream (new FileOutputStream ("update.txt" ));
24- System .setOut (out );
2525
2626 String is = request ("https://raw.githubusercontent.com/nacrt/SkyblockClient-REPO/main/files/mods.json" );
2727
2828 String fldmds = System .getenv ("APPDATA" ) + "\\ .minecraft\\ skyclient\\ mods" ;
2929
3030 String [] filelist = new File (fldmds ).list ();
3131
32+ System .out .println ();
33+
34+ if (System .console () == null ) {
35+ javax .swing .JOptionPane .showMessageDialog ( null , "Run run.bat u dumbass\n not this jar" );
36+ System .exit (0 );
37+ }
38+
3239 if (filelist == null ) {
3340 System .exit (0 );
3441 }
@@ -49,7 +56,7 @@ public static void main(String[] args) throws IOException {
4956 int z = tstarray .stream ().mapToInt (v -> v ).min ().orElse (Integer .MAX_VALUE );
5057
5158 if (tstarray .get (y ) == z ) {
52- if (!(z < 4 ) && (z < 15 )){
59+ if (!(z < 1 ) && (z < 15 )){
5360 to_be_updated_fn .add (filelist [i ]);
5461 to_be_updated_n .add (namesJson .get (y ));
5562 }
@@ -58,45 +65,60 @@ public static void main(String[] args) throws IOException {
5865
5966 }
6067
68+ System .out .println ("Found " +to_be_updated_n .size ()+" mods that need to be updated" );
6169 for (int i = 0 ; i < to_be_updated_n .size (); i ++) {
6270 for (int x = 0 ; x < namesJson .size (); x ++) {
63- try {
64-
65- if (("" + namesJson .get (x )).equals ("" + to_be_updated_n .get (i ))) {
66-
71+ if (("" + namesJson .get (x )).equals ("" + to_be_updated_n .get (i ))) {
72+ JSONObject obj = new JSONObject (arry .get (x ).toString ());
73+ String dpname = (String ) obj .get ("display" );
74+ System .out .println ("" );
75+ System .out .println ("Do you want to update " +dpname +"\n " +"From: " + to_be_updated_fn .get (i ) + "\n " + "To: " + to_be_updated_n .get (i ));
76+
77+ Scanner sc = new Scanner (System .in ); //System.in is a standard input stream
78+ System .out .print ("[y/n]: " );
79+ String str = sc .nextLine ();
80+ if (str .equalsIgnoreCase ("n" ) || str .equalsIgnoreCase ("no" )) {
81+
82+ } else {
83+ to_be_updated_n_p .add (to_be_updated_n .get (i ));
84+ to_be_updated_fn_p .add (to_be_updated_fn .get (i ));
85+ }
86+ }
87+ }
88+ }
6789
90+ for (int i = 0 ; i < to_be_updated_n_p .size (); i ++) {
91+ for (int x = 0 ; x < namesJson .size (); x ++) {
92+ try {
93+ if (("" + namesJson .get (x )).equals ("" + to_be_updated_n_p .get (i ))) {
6894 JSONObject obj = new JSONObject (arry .get (x ).toString ());
6995 String dpname = (String ) obj .get ("display" );
7096 String url ;
71- File todel = new File (fldmds +"\\ " +to_be_updated_fn .get (i ));
72-
97+ File todel = new File (fldmds +"\\ " +to_be_updated_fn_p .get (i ));
7398 if (obj .get ("id" ) == "rpm" || obj .get ("id" ) == "hudcaching" ) {
74- url = "https://github.com/nacrt/SkyblockClient-REPO/blob/main/files/mods/" +to_be_updated_fn .get (i )+"?raw=true" ;
99+ url = "https://github.com/nacrt/SkyblockClient-REPO/blob/main/files/mods/" +to_be_updated_fn_p .get (i )+"?raw=true" ;
75100 } else {
76101 url = (String ) obj .get ("url" );
77102 }
78-
79-
80-
81103 try {
82104 Download ("" +url , fldmds + "\\ " + namesJson .get (x ));
83105 todel .delete ();
106+ System .out .println ("" );
84107 System .out .println ("Updated: " + dpname );
85- System .out .println ("From: " + to_be_updated_fn .get (i ) + "\n " + "To: " + to_be_updated_n .get (i ));
108+ System .out .println ("From: " + to_be_updated_fn_p .get (i ) + "\n " + "To: " + to_be_updated_n_p .get (i ));
86109 } catch (IOException e ) {
87110 e .getStackTrace ();
88111 System .out .println ("Failed to download " +namesJson .get (x )+"\n Try again later" );
89112 errors = errors + 1 ;
90113 }
91-
92114 }
93115 } catch (Exception e ) {
94116 System .out .println ("Exception at: " +x );
95117 }
96118 }
97119 }
98120
99-
121+ System . out . println ( "" );
100122 if (errors == 1 ) {
101123 System .out .println ("Done\n " +errors +" download failed" );
102124 } else {
0 commit comments