Mitigate issues with tree generation in paper (#260)

* fix: mitigate cocoa tree generation crash

* chore: suppress warnings

* chore: fix formatting

* refactor: catch specific exception

* chore: added reference to PaperMC/Paper#6028
This commit is contained in:
Cubxity 2021-09-06 21:44:43 +02:00 committed by GitHub
parent eef0e04682
commit d7bb818f51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -46,6 +46,8 @@ public class BukkitTree implements Tree {
public boolean plant(Location l, Random r) {
try(ProfileFrame ignore = main.getProfiler().profile("bukkit_tree:" + delegate.toString().toLowerCase(Locale.ROOT))) {
return ((BukkitWorld) l.getWorld()).getHandle().generateTree(BukkitAdapter.adapt(l), delegate);
} catch(IndexOutOfBoundsException ignored) { // Workaround for https://github.com/PaperMC/Paper/issues/6028
return false;
}
}