mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-24 03:35:11 +01:00
Solve crashes with Addon#allLoaded call (#1959)
If some addon has code in Addon#allLoaded that crashes the call, then it did not disable addon as well as did not call allLoaded for every other addon that was left in the list. This should be solved by adding an extra try-catch.
This commit is contained in:
parent
9f21314818
commit
36751d5573
@ -666,7 +666,28 @@ public class AddonsManager {
|
||||
* @since 1.8.0
|
||||
*/
|
||||
public void allLoaded() {
|
||||
addons.forEach(Addon::allLoaded);
|
||||
this.getEnabledAddons().forEach(this::allLoaded);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method calls Addon#allLoaded in safe manner. If for some reason addon crashes on Addon#allLoaded, then
|
||||
* it will disable itself without harming other addons.
|
||||
* @param addon Addon that should trigger Addon#allLoaded method.
|
||||
*/
|
||||
private void allLoaded(@NonNull Addon addon) {
|
||||
try {
|
||||
addon.allLoaded();
|
||||
} catch (NoClassDefFoundError | NoSuchMethodError | NoSuchFieldError e) {
|
||||
// Looks like the addon is incompatible, because it tries to refer to missing classes...
|
||||
this.handleAddonIncompatibility(addon, e);
|
||||
// Disable addon.
|
||||
this.disable(addon);
|
||||
} catch (Exception e) {
|
||||
// Unhandled exception. We'll give a bit of debug here.
|
||||
this.handleAddonError(addon, e);
|
||||
// Disable addon.
|
||||
this.disable(addon);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user