Fix improper target block handing in /tree & /bigtree (#3271)

This commit is contained in:
Josh Roy 2020-05-13 18:55:17 -04:00 committed by GitHub
parent 302f0acbaa
commit b960ee365a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 6 deletions

View file

@ -33,9 +33,11 @@ public class Commandbigtree extends EssentialsCommand {
throw new NotEnoughArgumentsException();
}
final Location loc = LocationUtil.getTarget(user.getBase());
final Location safeLocation = LocationUtil.getSafeDestination(loc);
final boolean success = user.getWorld().generateTree(safeLocation, tree);
final Location loc = LocationUtil.getTarget(user.getBase()).add(0, 1, 0);
if (!user.getWorld().getBlockAt(loc).isPassable()) {
throw new Exception(tl("bigTreeFailure"));
}
final boolean success = user.getWorld().generateTree(loc, tree);
if (success) {
user.sendMessage(tl("bigTreeSuccess"));
} else {

View file

@ -42,9 +42,11 @@ public class Commandtree extends EssentialsCommand {
}
}
final Location loc = LocationUtil.getTarget(user.getBase());
final Location safeLocation = LocationUtil.getSafeDestination(loc);
final boolean success = user.getWorld().generateTree(safeLocation, tree);
final Location loc = LocationUtil.getTarget(user.getBase()).add(0, 1, 0);
if (!user.getWorld().getBlockAt(loc).isPassable()) {
throw new Exception(tl("treeFailure"));
}
final boolean success = user.getWorld().generateTree(loc, tree);
if (success) {
user.sendMessage(tl("treeSpawned"));
} else {