Make plugin check before register to avoid possible exceptions

This commit is contained in:
Andre601 2022-05-19 02:46:40 +02:00
parent 0ac62d6b63
commit 651e14a797
1 changed files with 8 additions and 8 deletions

View File

@ -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();
}