@@ -77,7 +77,7 @@ private void checkAndSetVersion(String str)
7777 }
7878
7979 // promotions
80- if (this .forgeJson .promos .containsKey (str ))
80+ if (this .forgeJson != null && this . forgeJson . promos != null && this . forgeJson .promos .containsKey (str ))
8181 {
8282 boolean worked = getFromBuildNumber (this .forgeJson .promos .get (str ));
8383 LOGGER .lifecycle ("Selected version " + this .forgeVersion );
@@ -90,36 +90,53 @@ private void checkAndSetVersion(String str)
9090 if (matcher .matches ())
9191 {
9292 String branch = Strings .emptyToNull (matcher .group (3 ));
93-
9493 String forgeVersion = matcher .group (1 );
95- ForgeBuild build = this .forgeJson .number .get (Integer .valueOf (matcher .group (2 )));
9694
97- if ( build == null )
95+ try
9896 {
99- throw new GradleConfigurationException ("No such version exists!" );
100- }
101-
102- boolean branchMatches = false ;
103- if (branch == null )
104- branchMatches = Strings .isNullOrEmpty (build .branch );
105- else
106- branchMatches = branch .substring (1 ).equals (build .branch );
97+ ForgeBuild build = this .forgeJson .number .get (Integer .valueOf (matcher .group (2 )));
98+
99+ if (build == null )
100+ {
101+ throw new GradleConfigurationException ("No such version exists!" );
102+ }
103+
104+ boolean branchMatches = false ;
105+ if (branch == null )
106+ branchMatches = Strings .isNullOrEmpty (build .branch );
107+ else
108+ branchMatches = branch .substring (1 ).equals (build .branch );
109+
110+ String outBranch = build .branch ;
111+ if (outBranch == null )
112+ outBranch = "" ;
113+ else
114+ outBranch = "-" + build .branch ;
115+
116+ if (!build .version .equals (forgeVersion ) || !branchMatches )
117+ {
118+ throw new GradleConfigurationException (str + " is an invalid version! did you mean '" + build .version + outBranch + "' ?" );
119+ }
120+
121+ version = build .mcversion .replace ("_" , "-" );
122+ this .forgeVersion = build .version ;
123+ if (!Strings .isNullOrEmpty (build .branch ) && !"null" .equals (build .branch ))
124+ this .forgeVersion += outBranch ;
107125
108- String outBranch = build .branch ;
109- if (outBranch == null )
110- outBranch = "" ;
111- else
112- outBranch = "-" + build .branch ;
113-
114- if (!build .version .equals (forgeVersion ) || !branchMatches )
126+ }
127+ catch (GradleConfigurationException e )
115128 {
116- throw new GradleConfigurationException ( str + " is an invalid version! did you mean '" + build . version + outBranch + "' ?" ) ;
129+ throw e ;
117130 }
131+ catch (Exception e )// everythng but the gradle exception
132+ {
133+ System .out .println ("Error occurred parsing version!" );
118134
119- version = build .mcversion .replace ("_" , "-" );
120- this .forgeVersion = build .version ;
121- if (!Strings .isNullOrEmpty (build .branch ) && !"null" .equals (build .branch ))
122- this .forgeVersion += outBranch ;
135+ version = "1.8" ;// just gonna guess.. since we dont know..
136+ this .forgeVersion = forgeVersion ;
137+ if (!Strings .isNullOrEmpty (branch ) && !"null" .equals (branch ))
138+ this .forgeVersion += branch ;
139+ }
123140
124141 return ;
125142 }
@@ -134,44 +151,60 @@ private void checkAndSetVersion(String str)
134151 String forgeVersion = matcher .group (2 );
135152 String buildNumber = matcher .group (3 );
136153
137- if ( "0" . equals ( buildNumber ))
154+ try
138155 {
139- LOGGER .lifecycle ("Assuming custom forge version!" );
140- version = mcversion ;
141- this .forgeVersion = forgeVersion + branch ;
142- return ;
156+ if ("0" .equals (buildNumber ))
157+ {
158+ LOGGER .lifecycle ("Assuming custom forge version!" );
159+ version = mcversion ;
160+ this .forgeVersion = forgeVersion + branch ;
161+ return ;
162+ }
163+
164+ ForgeBuild build = this .forgeJson .number .get (Integer .parseInt (buildNumber ));
165+
166+ if (build == null )
167+ {
168+ throw new GradleConfigurationException ("No such version exists!" );
169+ }
170+
171+ boolean branchMatches = false ;
172+ if (Strings .isNullOrEmpty (branch ))
173+ branchMatches = Strings .isNullOrEmpty (build .branch );
174+ else
175+ branchMatches = branch .substring (1 ).equals (build .branch );
176+
177+ boolean mcMatches = build .mcversion .equals (mcversion );
178+
179+ String outBranch = build .branch ;
180+ if (outBranch == null )
181+ outBranch = "" ;
182+ else
183+ outBranch = "-" + build .branch ;
184+
185+ if (!build .version .equals (forgeVersion ) || !branchMatches || !mcMatches )
186+ {
187+ throw new GradleConfigurationException (str + " is an invalid version! did you mean '" + build .mcversion + "-" + build .version + outBranch + "' ?" );
188+ }
189+
190+ version = build .mcversion .replace ("_" , "-" );
191+ this .forgeVersion = build .version ;
192+ if (!Strings .isNullOrEmpty (build .branch ) && !"null" .equals (build .branch ))
193+ this .forgeVersion += outBranch ;
143194 }
144-
145- ForgeBuild build = this .forgeJson .number .get (Integer .parseInt (buildNumber ));
146-
147- if (build == null )
195+ catch (GradleConfigurationException e )
148196 {
149- throw new GradleConfigurationException ( "No such version exists!" ) ;
197+ throw e ;
150198 }
151-
152- boolean branchMatches = false ;
153- if (Strings .isNullOrEmpty (branch ))
154- branchMatches = Strings .isNullOrEmpty (build .branch );
155- else
156- branchMatches = branch .substring (1 ).equals (build .branch );
157-
158- boolean mcMatches = build .mcversion .equals (mcversion );
159-
160- String outBranch = build .branch ;
161- if (outBranch == null )
162- outBranch = "" ;
163- else
164- outBranch = "-" + build .branch ;
165-
166- if (!build .version .equals (forgeVersion ) || !branchMatches || !mcMatches )
199+ catch (Exception e )// everythng but the gradle exception
167200 {
168- throw new GradleConfigurationException (str + " is an invalid version! did you mean '" + build .mcversion + "-" + build .version + outBranch + "' ?" );
169- }
201+ System .out .println ("Error occurred parsing version!" );
170202
171- version = build .mcversion .replace ("_" , "-" );
172- this .forgeVersion = build .version ;
173- if (!Strings .isNullOrEmpty (build .branch ) && !"null" .equals (build .branch ))
174- this .forgeVersion += outBranch ;
203+ version = mcversion ;
204+ this .forgeVersion = forgeVersion ;
205+ if (!Strings .isNullOrEmpty (branch ) && !"null" .equals (branch ))
206+ this .forgeVersion += branch ;
207+ }
175208
176209 return ;
177210 }
0 commit comments