diff --git a/src/main/java/net/rptools/maptool/client/AppSetup.java b/src/main/java/net/rptools/maptool/client/AppSetup.java index 5543850fac..3bbf22149e 100644 --- a/src/main/java/net/rptools/maptool/client/AppSetup.java +++ b/src/main/java/net/rptools/maptool/client/AppSetup.java @@ -20,6 +20,7 @@ import java.net.URL; import java.util.Set; import java.util.regex.Pattern; +import java.util.stream.Collectors; import javax.swing.*; import net.rptools.lib.FileUtil; import net.rptools.maptool.model.AssetManager; @@ -28,7 +29,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.reflections.Reflections; -import org.reflections.scanners.ResourcesScanner; +import org.reflections.scanners.Scanners; +import org.reflections.util.ConfigurationBuilder; /** Executes only the first time the application is run. */ public class AppSetup { @@ -67,10 +69,15 @@ private static void installPredefinedProperties() { } private static void installUsingReflection(String source, File dir, String name) { - if (isNotEmpty(dir)) return; - - Reflections reflections = new Reflections(source, new ResourcesScanner()); - Set resourcePathSet = reflections.getResources(Pattern.compile(".*")); + if (isNotEmpty(dir)) { + return; + } + Set resourcePathSet = + new Reflections( + new ConfigurationBuilder().forPackage(source).setScanners(Scanners.Resources)) + .getResources(Pattern.compile(".*")).stream() + .filter(s -> s.startsWith(source)) + .collect(Collectors.toSet()); for (String resourcePath : resourcePathSet) { URL inputUrl = AppSetup.class.getClassLoader().getResource(resourcePath); @@ -97,9 +104,18 @@ private static boolean isNotEmpty(File dir) { */ public static void installDefaultUIThemes() { if (!themesInstalled) { - Reflections reflections = - new Reflections(AppConstants.DEFAULT_UI_THEMES, new ResourcesScanner()); - Set resourcePathSet = reflections.getResources(Pattern.compile(".*\\.theme")); + Set resourcePathSet = + new Reflections( + new ConfigurationBuilder() + .forPackage(AppConstants.DEFAULT_UI_THEMES) + .setScanners(Scanners.Resources)) + .getResources(Pattern.compile(".*")).stream() + .filter(s -> s.startsWith(AppConstants.DEFAULT_UI_THEMES)) + .collect(Collectors.toSet()) + .stream() + .filter(s -> s.endsWith(".theme")) + .filter(s -> s.startsWith(AppConstants.DEFAULT_UI_THEMES)) + .collect(Collectors.toSet()); for (String resourcePath : resourcePathSet) { URL inputUrl = AppSetup.class.getClassLoader().getResource(resourcePath);