gurkenlabs / litiengine

LITIENGINE 🕹 The pure 2D java game engine.
https://litiengine.com/
MIT License
718 stars 94 forks source link

Synchronizing maps throws an exception when there is no maps directory in the project root #806

Open nightm4re94 opened 6 months ago

nightm4re94 commented 6 months ago

Describe the bug Java projects don't usually store their resources in the root folder, but in e.g. src/main/resources. When you have the "synchronize maps" feature active in utiLITI, it can't locate such maps folders and crashes.

Stack Trace The error message you get either in your console or the crash.txt located in your program's root directory.

java.nio.file.NoSuchFileException: E:\Git\legendsofliti\maps
    at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:85)
    at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103)
    at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:108)
    at java.base/sun.nio.fs.WindowsDirectoryStream.<init>(WindowsDirectoryStream.java:86)
    at java.base/sun.nio.fs.WindowsFileSystemProvider.newDirectoryStream(WindowsFileSystemProvider.java:541)
    at java.base/java.nio.file.Files.newDirectoryStream(Files.java:481)
    at de.gurkenlabs.litiengine.util.io.FileUtilities.findFilesByExtension(FileUtilities.java:49)
    at de.gurkenlabs.utiliti.components.Editor.saveMaps(Editor.java:821)
    at de.gurkenlabs.utiliti.components.Editor.saveGameFile(Editor.java:812)
    at de.gurkenlabs.utiliti.components.Editor.save(Editor.java:729)
    at de.gurkenlabs.utiliti.swing.menus.FileMenu.lambda$new$4(FileMenu.java:44)
    at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1972)
    at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2314)
    at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:407)
    at java.desktop/javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:262)
    at java.desktop/javax.swing.AbstractButton.doClick(AbstractButton.java:374)
    at java.desktop/javax.swing.AbstractButton.doClick(AbstractButton.java:354)
    at java.desktop/javax.swing.plaf.basic.BasicMenuItemUI$Actions.actionPerformed(BasicMenuItemUI.java:984)
    at java.desktop/javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1810)
    at java.desktop/javax.swing.JComponent.processKeyBinding(JComponent.java:2956)
    at java.desktop/javax.swing.JMenuBar.processBindingForKeyStrokeRecursive(JMenuBar.java:709)
    at java.desktop/javax.swing.JMenuBar.processBindingForKeyStrokeRecursive(JMenuBar.java:715)
    at java.desktop/javax.swing.JMenuBar.processBindingForKeyStrokeRecursive(JMenuBar.java:715)
    at java.desktop/javax.swing.JMenuBar.processKeyBinding(JMenuBar.java:688)
    at java.desktop/javax.swing.KeyboardManager.fireBinding(KeyboardManager.java:309)
    at java.desktop/javax.swing.KeyboardManager.fireKeyboardAction(KeyboardManager.java:295)
    at java.desktop/javax.swing.JComponent.processKeyBindingsForAllComponents(JComponent.java:3049)
    at java.desktop/javax.swing.JComponent.processKeyBindings(JComponent.java:3041)
    at java.desktop/javax.swing.SwingUtilities.processKeyBindings(SwingUtilities.java:1724)
    at java.desktop/javax.swing.UIManager$2.postProcessKeyEvent(UIManager.java:1545)
    at java.desktop/java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:891)
    at java.desktop/java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:1146)
    at java.desktop/java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:1020)
    at java.desktop/java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:848)
    at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:4877)
    at java.desktop/java.awt.Component.dispatchEvent(Component.java:4828)
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:775)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:720)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:714)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:87)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:98)
    at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:747)
    at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:745)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:87)
    at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:744)
    at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

Expected behavior No crash pls