File tree Expand file tree Collapse file tree 1 file changed +22
-4
lines changed
src/main/java/com/falsepattern/lib/mixin Expand file tree Collapse file tree 1 file changed +22
-4
lines changed Original file line number Diff line number Diff line change 33
33
34
34
import java .io .File ;
35
35
import java .io .FileNotFoundException ;
36
- import java .io . IOException ;
36
+ import java .net . URL ;
37
37
import java .nio .file .Path ;
38
+ import java .nio .file .Paths ;
38
39
import java .util .ArrayList ;
39
40
import java .util .Arrays ;
40
41
import java .util .List ;
@@ -55,12 +56,29 @@ static Logger createLogger(String modName) {
55
56
56
57
@ StableAPI .Expose
57
58
static File findJarOf (final ITargetedMod mod ) {
59
+ File result = null ;
58
60
try (val stream = walk (MODS_DIRECTORY_PATH )) {
59
- return stream .filter (mod ::isMatchingJar ).map (Path ::toFile ).findFirst ().orElse (null );
60
- } catch (IOException e ) {
61
+ result = stream .filter (mod ::isMatchingJar )
62
+ .map (Path ::toFile )
63
+ .findFirst ()
64
+ .orElse (null );
65
+ } catch (Exception e ) {
61
66
e .printStackTrace ();
62
- return null ;
63
67
}
68
+ if (result == null ) {
69
+ try {
70
+ result = Arrays .stream (Launch .classLoader .getURLs ())
71
+ .map (URL ::getPath )
72
+ .map (Paths ::get )
73
+ .filter (mod ::isMatchingJar )
74
+ .map (Path ::toFile )
75
+ .findFirst ()
76
+ .orElse (null );
77
+ } catch (Exception e ) {
78
+ e .printStackTrace ();
79
+ }
80
+ }
81
+ return result ;
64
82
}
65
83
66
84
@ StableAPI .Expose
You can’t perform that action at this time.
0 commit comments