9
9
import org .hydev .mcpm .utils .PluginJarFile ;
10
10
import org .hydev .mcpm .utils .StoredHashMap ;
11
11
import org .hydev .mcpm .utils .TemporaryDir ;
12
+ import org .yaml .snakeyaml .error .YAMLException ;
12
13
13
14
import java .io .File ;
14
15
import java .io .IOException ;
@@ -38,7 +39,7 @@ public class SpigetCrawler
38
39
"AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36" ;
39
40
private final long mtDelay = 1000 ;
40
41
private final File dataDir ;
41
- private final StoredHashMap <Long , String > blacklist ;
42
+ private final StoredHashMap <String , String > blacklist ;
42
43
43
44
public SpigetCrawler (File dataDir )
44
45
{
@@ -170,7 +171,7 @@ private File getLatestPath(SpigetResource res)
170
171
private void checkUpdate (SpigetResource res )
171
172
{
172
173
// Plugin is in the blacklist, skip
173
- if (blacklist .containsKey (res .id ())) return ;
174
+ if (blacklist .containsKey ("" + res .id ())) return ;
174
175
175
176
// Latest version already exists in local fs, skip
176
177
var fp = getLatestPath (res );
@@ -202,7 +203,7 @@ private void checkUpdate(SpigetResource res)
202
203
{
203
204
// Cannot read plugin.yml, that means it's not a standard plugin, add to blacklist
204
205
System .out .printf ("Cannot read plugin.yml (%s: %s)\n " , res .id (), res .name ());
205
- blacklist .put (res .id (), "Cannot read plugin.yml" );
206
+ blacklist .put ("" + res .id (), "Cannot read plugin.yml" );
206
207
return ;
207
208
}
208
209
@@ -221,15 +222,15 @@ private void checkUpdate(SpigetResource res)
221
222
{
222
223
// Not found
223
224
if (e .getMessage ().contains ("404" ))
224
- blacklist .put (res .id (), "HTTP 404: Not found" );
225
+ blacklist .put ("" + res .id (), "HTTP 404: Not found" );
225
226
226
227
// "External resource cannot be downloaded"
227
228
else if (e .getMessage ().contains ("400" ))
228
- blacklist .put (res .id (), "HTTP 400: Probably external resource" );
229
+ blacklist .put ("" + res .id (), "HTTP 400: Probably external resource" );
229
230
230
231
// Blocked by cloudflare
231
232
else if (e .getMessage ().contains ("520" ))
232
- blacklist .put (res .id (), "HTTP 520: External site, blocked by CloudFlare" );
233
+ blacklist .put ("" + res .id (), "HTTP 520: External site, blocked by CloudFlare" );
233
234
234
235
// This happens when the server has an error (e.g. when a plugin doesn't have files to download)
235
236
//else if (e.getMessage().contains("502")) return;
@@ -274,11 +275,11 @@ public void links()
274
275
linkPath .getParentFile ().mkdirs ();
275
276
createSymbolicLink (linkPath .toPath (), linkPath .getParentFile ().toPath ().relativize (ver .toPath ()));
276
277
}
277
- catch (IOException e )
278
+ catch (IOException | YAMLException | NullPointerException e )
278
279
{
279
280
// TODO: Better error handling
280
281
//e.printStackTrace();
281
- throw new RuntimeException ( e );
282
+ System . out . printf ( "Cannot read plugin.yml for %s: %s \n " , ver , e );
282
283
}
283
284
});
284
285
});
@@ -292,7 +293,7 @@ public void links()
292
293
public static void main (String [] args )
293
294
{
294
295
var crawler = new SpigetCrawler (new File (".mcpm" ));
295
- var res = crawler .crawlAllResources (false ).stream ()
296
+ var res = crawler .crawlAllResources (true ).stream ()
296
297
.filter (it -> it .downloads () > 100 && !it .external ()).toList ();
297
298
298
299
System .out .println (res .size ());
0 commit comments