Add try catch around second stage plugin loading task. (#1609)

https://github.com/BentoBoxWorld/BentoBox/issues/1281
This commit is contained in:
tastybento 2020-12-19 10:28:46 -08:00 committed by GitHub
parent 0e4b3b40fa
commit 9570f342ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 100 additions and 89 deletions

View File

@ -168,6 +168,15 @@ public class BentoBox extends JavaPlugin {
final long loadTime = System.currentTimeMillis() - loadStart;
Bukkit.getScheduler().runTask(instance, () -> {
try {
completeSetup(loadTime);
} catch (Exception e) {
fireCriticalError(e.getMessage(), "");
}
});
}
private void completeSetup(long loadTime) {
final long enableStart = System.currentTimeMillis();
hooksManager.registerHook(new PlaceholderAPIHook());
// Setup the Placeholders manager
@ -186,18 +195,7 @@ public class BentoBox extends JavaPlugin {
try {
islandsManager.load();
} catch (Exception e) {
logError("*****************CRITIAL ERROR!******************");
logError(e.getMessage());
//Arrays.stream(e.getMessage().split("[\n\r]+")).forEach(this::logError);
logError("Could not load islands! Disabling BentoBox...");
logError("*************************************************");
// Stop all addons
if (addonsManager != null) {
addonsManager.disableAddons();
}
// Do not save players or islands, just shutdown
shutdown = true;
instance.setEnabled(false);
fireCriticalError(e.getMessage(), "Could not load islands!");
return;
}
@ -260,7 +258,20 @@ public class BentoBox extends JavaPlugin {
logWarning("There is NO guarantee YAML database will remain properly supported in the following updates, and its usage should as such be considered a non-viable situation.");
logWarning("*** *** *** *** *** *** *** *** *** *** ***");
}
});
}
private void fireCriticalError(String message, String error) {
logError("*****************CRITIAL ERROR!******************");
logError(message);
logError(error + " Disabling BentoBox...");
logError("*************************************************");
// Stop all addons
if (addonsManager != null) {
addonsManager.disableAddons();
}
// Do not save players or islands, just shutdown
shutdown = true;
instance.setEnabled(false);
}
/**