ignore hidden files when loading addons

This commit is contained in:
dfsek
2022-01-15 19:01:24 -07:00
parent 7939005428
commit fc10d0c303
@@ -65,7 +65,7 @@ public class ManifestAddonLoader implements BootstrapBaseAddon<ManifestAddon> {
AddonManifest manifest = manifestLoader.load(new AddonManifest(), AddonManifest manifest = manifestLoader.load(new AddonManifest(),
new YamlConfiguration(jar.getInputStream(manifestEntry), new YamlConfiguration(jar.getInputStream(manifestEntry),
"terra.addon.yml")); "terra.addon.yml"));
logger.debug("Loading addon {}@{}", manifest.getID(), manifest.getVersion().getFormatted()); logger.debug("Loading addon {}@{}", manifest.getID(), manifest.getVersion().getFormatted());
if(manifest.getSchemaVersion() != 1) { if(manifest.getSchemaVersion() != 1) {
@@ -107,10 +107,12 @@ public class ManifestAddonLoader implements BootstrapBaseAddon<ManifestAddon> {
logger.debug("Loading addons..."); logger.debug("Loading addons...");
try(Stream<Path> files = Files.walk(addonsFolder, 1, FileVisitOption.FOLLOW_LINKS)) { try(Stream<Path> files = Files.walk(addonsFolder, 1, FileVisitOption.FOLLOW_LINKS)) {
List<Path> addons = files.filter(path -> path.toFile().isFile()) List<Path> addons = files
.filter(path -> path.toFile().canRead()) .filter(path -> path.toFile().isFile())
.filter(path -> path.toString().endsWith(".jar")) .filter(path -> path.toFile().canRead())
.toList(); .filter(path -> !path.getFileName().startsWith(".")) // ignore hidden files.
.filter(path -> path.toString().endsWith(".jar"))
.toList();
ManifestAddonClassLoader loader = new ManifestAddonClassLoader(addons.stream().map(path -> { ManifestAddonClassLoader loader = new ManifestAddonClassLoader(addons.stream().map(path -> {
try { try {