From 651e14a797bacfc1397455386355b8df4cfe0e37 Mon Sep 17 00:00:00 2001 From: Andre601 <11576465+Andre601@users.noreply.github.com> Date: Thu, 19 May 2022 02:46:40 +0200 Subject: [PATCH] Make plugin check before register to avoid possible exceptions --- .../expansion/manager/LocalExpansionManager.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/me/clip/placeholderapi/expansion/manager/LocalExpansionManager.java b/src/main/java/me/clip/placeholderapi/expansion/manager/LocalExpansionManager.java index bdc4cca..b5aefc7 100644 --- a/src/main/java/me/clip/placeholderapi/expansion/manager/LocalExpansionManager.java +++ b/src/main/java/me/clip/placeholderapi/expansion/manager/LocalExpansionManager.java @@ -180,15 +180,15 @@ public final class LocalExpansionManager implements Listener { Objects.requireNonNull(expansion.getIdentifier(), "The expansion identifier is null!"); Objects.requireNonNull(expansion.getVersion(), "The expansion version is null!"); - if (!expansion.register()) { - if (expansion.getRequiredPlugin() != null && !expansion.getRequiredPlugin().isEmpty()) { - if (!Bukkit.getPluginManager().isPluginEnabled(expansion.getRequiredPlugin())) { - Msg.warn("Cannot load expansion %s due to a missing plugin: %s", - expansion.getIdentifier(), expansion.getRequiredPlugin()); - return Optional.empty(); - } + if (expansion.getRequiredPlugin() != null && !expansion.getRequiredPlugin().isEmpty()) { + if (!Bukkit.getPluginManager().isPluginEnabled(expansion.getRequiredPlugin())) { + Msg.warn("Cannot load expansion %s due to a missing Plugin: %s", expansion.getIdentifier(), + expansion.getRequiredPlugin()); + return Optional.empty(); } - + } + + if (!expansion.register()) { Msg.warn("Cannot load expansion %s due to an unknown issue.", expansion.getIdentifier()); return Optional.empty(); }