File tree Expand file tree Collapse file tree
lib/src/main/java/me/hsgamer/mcserverupdater/api Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -66,20 +66,18 @@ protected JSONObject getReleaseByTag(String tag) {
6666 }
6767 }
6868
69- protected JSONObject getReleaseByTagMatch (Predicate <String > tagPredicate ) {
70- String url = releasesUrl ;
69+ protected JSONObject getReleaseByPredicate (Predicate <JSONObject > predicate ) {
7170 int page = 1 ;
7271 while (true ) {
73- String pageUrl = url + "?per_page=100&page=" + page ;
72+ String pageUrl = releasesUrl + "?per_page=100&page=" + page ;
7473 debug ("Getting release from " + pageUrl );
7574 try {
7675 URLConnection connection = UserAgent .CHROME .assignToConnection (WebUtils .createConnection (pageUrl ));
7776 InputStream inputStream = connection .getInputStream ();
7877 JSONArray array = new JSONArray (new JSONTokener (inputStream ));
7978 for (int i = 0 ; i < array .length (); i ++) {
8079 JSONObject object = array .getJSONObject (i );
81- String tag = object .getString ("tag_name" );
82- if (tagPredicate .test (tag )) {
80+ if (predicate .test (object )) {
8381 return object ;
8482 }
8583 }
@@ -94,6 +92,10 @@ protected JSONObject getReleaseByTagMatch(Predicate<String> tagPredicate) {
9492 throw new RuntimeException ("Cannot find the release" );
9593 }
9694
95+ protected JSONObject getReleaseByTagMatch (Predicate <String > tagPredicate ) {
96+ return getReleaseByPredicate (object -> tagPredicate .test (object .getString ("tag_name" )));
97+ }
98+
9799 private String getBuild () {
98100 JSONObject object = getReleaseObject ();
99101 if (object == null ) {
You can’t perform that action at this time.
0 commit comments