Implement util method to check if y is within world build limits

This commit is contained in:
dordsor21
2022-06-20 12:11:41 +01:00
parent ca7e9c9bd8
commit 738f89f5dd
5 changed files with 26 additions and 31 deletions

View File

@ -624,6 +624,16 @@ public abstract class PlotArea {
getRegionAbs() == null || this.region.contains(location.getBlockVector3()));
}
/**
* Get if the PlotArea's build range (min build height -> max build height) contains the given y value
*
* @param y y height
* @return if build height contains y
*/
public boolean buildRangeContainsY(int y) {
return y >= minBuildHeight && y < maxBuildHeight;
}
public @NonNull Set<Plot> getPlotsAbs(final UUID uuid) {
if (uuid == null) {
return Collections.emptySet();

View File

@ -332,8 +332,7 @@ public class EventDispatcher {
) {
PlotArea area = location.getPlotArea();
assert area != null;
if ((location.getY() >= area.getMaxBuildHeight() || location.getY() < area
.getMinBuildHeight()) && !Permissions
if (!area.buildRangeContainsY(location.getY()) && !Permissions
.hasPermission(player, Permission.PERMISSION_ADMIN_BUILD_HEIGHT_LIMIT)) {
player.sendMessage(
TranslatableCaption.of("height.height_limit"),