CallMeFoxie / MewnbaseModded

3 stars 1 forks source link

Error, if launching with 0 mods #6

Open lipki opened 5 years ago

lipki commented 5 years ago

I managed to launch the modded game in the IDE. I have a first mistake, not too serious.

/usr/lib/jvm/java-1.8.0-openjdk-amd64/bin/java ...
MewnBase launch args: 
MewnBase: MoonBase.coreFolder = 
MewnBase: SettingsLoader: validating settings file
MewnBase: Vsync: true
MewnBase: SettingsLoader: Writing settings to disk.
MewnBase: SettingsLoader: Writing settings to disk.
java.lang.NullPointerException
    at eu.foxiemods.mewnloader.MewnLoader.init(MewnLoader.java:58)
    at com.cairn4.moonbase.MoonBase.create(MoonBase.java:77)
    at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Window.initializeListener(Lwjgl3Window.java:422)
    at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Window.update(Lwjgl3Window.java:370)
    at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application.loop(Lwjgl3Application.java:137)
    at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application.<init>(Lwjgl3Application.java:111)
    at com.cairn4.moonbase.desktop.DesktopLauncher.main(DesktopLauncher.java:42)

Process finished with exit code 0

Provoked if no mod exists in the mods folder.

Solved by :

      if( files != null ) { // If no mod.
         for(File file : files) {
            if(file.isFile() && file.getName().endsWith(".jar")) {
               try {
                  method.invoke(systemClassLoader, new Object[] {file.toURI().toURL()});
               } catch (MalformedURLException e) {
                  e.printStackTrace();
               } catch (IllegalAccessException e) {
                  e.printStackTrace();
               } catch (InvocationTargetException e) {
                  e.printStackTrace();
               }
            }
         }
      }