From da882301bcf7cd638c26c71047c247520ed435ad Mon Sep 17 00:00:00 2001 From: Vankka Date: Fri, 4 Mar 2022 12:52:21 +0200 Subject: [PATCH] Change NPE to IllegalState in Sponge loader's jarinjar presence check --- .../discordsrv/sponge/loader/DiscordSRVSpongeLoader.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sponge/loader/src/main/java/com/discordsrv/sponge/loader/DiscordSRVSpongeLoader.java b/sponge/loader/src/main/java/com/discordsrv/sponge/loader/DiscordSRVSpongeLoader.java index ed49c1aa..0efc1472 100644 --- a/sponge/loader/src/main/java/com/discordsrv/sponge/loader/DiscordSRVSpongeLoader.java +++ b/sponge/loader/src/main/java/com/discordsrv/sponge/loader/DiscordSRVSpongeLoader.java @@ -39,7 +39,6 @@ import java.io.IOException; import java.lang.reflect.Constructor; import java.net.URL; import java.nio.file.Path; -import java.util.Objects; import java.util.Optional; @Plugin("discordsrv") @@ -102,7 +101,11 @@ public class DiscordSRVSpongeLoader implements ILoader { @Override public @NotNull URL getJarInJarResource() { - return Objects.requireNonNull(getParentClassLoader().getResource("sponge.jarinjar")); + URL resource = getParentClassLoader().getResource("sponge.jarinjar"); + if (resource == null) { + throw new IllegalStateException("Jar does not contain jarinjar"); + } + return resource; } @Listener