Skip to content

Commit 63e31fe

Browse files
committed
[F] PluginLoader: Fix not found exception throwing
1 parent d4befd3 commit 63e31fe

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/main/java/org/hydev/mcpm/client/injector/PluginLoader.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,18 @@ public class PluginLoader implements LoadBoundary, UnloadBoundary, ReloadBoundar
3232
public boolean loadPlugin(String name) throws PluginNotFoundException
3333
{
3434
// 1. Find plugin file by name
35-
var nf = new PluginNotFoundException(name);
3635
var dir = new File("plugins");
37-
if (!dir.isDirectory()) throw nf;
38-
var file = Arrays.stream(Optional.ofNullable(dir.listFiles()).orElseThrow(() -> nf))
36+
if (!dir.isDirectory()) throw new PluginNotFoundException(name);
37+
var file = Arrays.stream(Optional.ofNullable(dir.listFiles())
38+
.orElseThrow(() -> new PluginNotFoundException(name)))
3939
.filter(f -> f.getName().endsWith(".jar"))
4040
.filter(f -> {
4141
try (var jf = new PluginJarFile(f))
4242
{
4343
return jf.readPluginYaml().getName().equalsIgnoreCase(name);
4444
}
4545
catch (IOException ignored) { return false; }
46-
}).findFirst().orElseThrow(() -> nf);
46+
}).findFirst().orElseThrow(() -> new PluginNotFoundException(name));
4747

4848
return loadPlugin(file);
4949
}

0 commit comments

Comments
 (0)