Add try catch around second stage plugin loading task. (#1609)
https://github.com/BentoBoxWorld/BentoBox/issues/1281
This commit is contained in:
parent
0e4b3b40fa
commit
9570f342ee
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue