diff --git a/src/main/java/me/clip/placeholderapi/util/FileUtil.java b/src/main/java/me/clip/placeholderapi/util/FileUtil.java index 6bed142..825ff54 100644 --- a/src/main/java/me/clip/placeholderapi/util/FileUtil.java +++ b/src/main/java/me/clip/placeholderapi/util/FileUtil.java @@ -42,13 +42,11 @@ public class FileUtil { } final URL jar = file.toURI().toURL(); - + final URLClassLoader loader = new URLClassLoader(new URL[]{jar}, clazz.getClassLoader()); final List matches = new ArrayList<>(); final List> classes = new ArrayList<>(); - try (final JarInputStream stream = new JarInputStream( - jar.openStream()); final URLClassLoader loader = new URLClassLoader(new URL[]{jar}, - clazz.getClassLoader())) { + try (final JarInputStream stream = new JarInputStream(jar.openStream())) { JarEntry entry; while ((entry = stream.getNextJarEntry()) != null) { final String name = entry.getName(); @@ -69,8 +67,11 @@ public class FileUtil { } } } - - return classes.isEmpty() ? null : classes.get(0); + if (classes.isEmpty()) { + loader.close(); + return null; + } + return classes.get(0); } }