66import javax .swing .*;
77import java .awt .*;
88import java .io .File ;
9+ import java .net .MalformedURLException ;
910import java .net .URL ;
10- import java .util .HashMap ;
11- import java .util .Objects ;
11+ import java .util .*;
1212import java .util .logging .Logger ;
13+ import java .util .regex .Pattern ;
1314
1415public class FoxLauncher {
1516 static {
@@ -44,6 +45,7 @@ public class FoxLauncher {
4445 public static final HashMap <String , Object > mixinProperties = new HashMap <>();
4546 static LauncherType launcherType = LauncherType .UNKNOWN ;
4647 private static boolean client , wronglyInstalled , wronglyInstalledUnrecoverable ;
48+ private static final LinkedList <File > filesToLoad = new LinkedList <>();
4749 static FoxClassLoader foxClassLoader ;
4850 static File gameDir ;
4951 public static String initialUsername ;
@@ -111,6 +113,7 @@ static void initForClientFromArgs(String[] args) {
111113 foxClassLoader .addTransformerExclusion ("com.fox2code.jfallback." );
112114 foxClassLoader .addTransformerExclusion ("com.fox2code.foxloader.loader." );
113115 installLoggerHelper (true ); // Install special logger before libraries loading
116+ initializeClassPath (); // Initialize class path before libraries loading
114117 DependencyHelper .loadDependencies (true );
115118 }
116119
@@ -159,9 +162,29 @@ static void initForServerFromArgs(String[] args) {
159162 foxClassLoader .addTransformerExclusion ("com.fox2code.jfallback." );
160163 foxClassLoader .addTransformerExclusion ("com.fox2code.foxloader.loader." );
161164 installLoggerHelper (false ); // Install special logger before libraries loading
165+ initializeClassPath (); // Initialize class path before libraries loading
162166 DependencyHelper .loadDependencies (false );
163167 }
164168
169+ private static void initializeClassPath () {
170+ String javaHome = System .getProperty ("java.home" );
171+ String classPath = System .getProperty ("java.class.path" );
172+ Pattern pattern = Pattern .compile (File .pathSeparator , Pattern .LITERAL );
173+ for (String path : pattern .split (classPath )) {
174+ if (path .startsWith (javaHome )) continue ;
175+ File file = new File (path ).getAbsoluteFile ();
176+ if (file .isDirectory ()) {
177+ try {
178+ foxClassLoader .addURL (file .toURI ().toURL ());
179+ } catch (MalformedURLException e ) {
180+ e .printStackTrace (hasLogger ? System .err : System .out );
181+ }
182+ } else {
183+ filesToLoad .add (file );
184+ }
185+ }
186+ }
187+
165188 private static void installLoggerHelper (boolean client ) {
166189 if (hasLogger ) return ;
167190 boolean installed = false ;
@@ -176,6 +199,10 @@ private static void installLoggerHelper(boolean client) {
176199 hasLogger = installed ;
177200 }
178201
202+ public static Iterator <File > fileToLoadIterator () {
203+ return filesToLoad .iterator ();
204+ }
205+
179206 public static void installLoggerHelperOn (Logger logger ) {
180207 if (hasLogger ) LoggerHelper .installOn (logger );
181208 }
0 commit comments