Skip to content

Commit

Permalink
Ref: height limit check (#4427)
Browse files Browse the repository at this point in the history
 - The notifyIfOutsideBuildArea method checks the limits and already includes sending the height.height_limit message. This does not need to be called again in the code.
  • Loading branch information
RedstoneFuture authored Jun 1, 2024
1 parent 4839a83 commit 215053e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.world.block.BlockType;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.tag.Tag;
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
import org.bukkit.Bukkit;
Expand Down Expand Up @@ -164,13 +163,6 @@ public void blockCreate(BlockPlaceEvent event) {
if (plot != null) {
if (area.notifyIfOutsideBuildArea(pp, location.getY())) {
event.setCancelled(true);
pp.sendMessage(
TranslatableCaption.of("height.height_limit"),
TagResolver.builder()
.tag("minheight", Tag.inserting(Component.text(area.getMinBuildHeight())))
.tag("maxheight", Tag.inserting(Component.text(area.getMaxBuildHeight())))
.build()
);
return;
}
if (!plot.hasOwner()) {
Expand Down Expand Up @@ -262,13 +254,6 @@ public void blockDestroy(BlockBreakEvent event) {
}
} else if (area.notifyIfOutsideBuildArea(plotPlayer, location.getY())) {
event.setCancelled(true);
plotPlayer.sendMessage(
TranslatableCaption.of("height.height_limit"),
TagResolver.builder()
.tag("minheight", Tag.inserting(Component.text(area.getMinBuildHeight())))
.tag("maxheight", Tag.inserting(Component.text(area.getMaxBuildHeight())))
.build()
);
return;
}
if (!plot.hasOwner()) {
Expand Down Expand Up @@ -1224,18 +1209,9 @@ public void onBlockMultiPlace(BlockMultiPlaceEvent event) {
if (pp.hasPermission(Permission.PERMISSION_ADMIN_BUILD_HEIGHT_LIMIT)) {
continue;
}
if (currentLocation.getY() >= area.getMaxBuildHeight() || currentLocation.getY() < area.getMinBuildHeight()) {
pp.sendMessage(
TranslatableCaption.of("height.height_limit"),
TagResolver.builder()
.tag("minheight", Tag.inserting(Component.text(area.getMinBuildHeight())))
.tag("maxheight", Tag.inserting(Component.text(area.getMaxBuildHeight())))
.build()
);
if (area.notifyIfOutsideBuildArea(pp, currentLocation.getY())) {
event.setCancelled(true);
break;
}
if (area.notifyIfOutsideBuildArea(pp, currentLocation.getY())) {
event.setCancelled(true);
break;
}
}

Expand Down
6 changes: 2 additions & 4 deletions Core/src/main/java/com/plotsquared/core/plot/PlotArea.java
Original file line number Diff line number Diff line change
Expand Up @@ -679,10 +679,8 @@ public boolean notifyIfOutsideBuildArea(PlotPlayer<?> player, int y) {
TranslatableCaption.of("height.height_limit"),
TagResolver.builder()
.tag("minheight", Tag.inserting(Component.text(minBuildHeight)))
.tag(
"maxheight",
Tag.inserting(Component.text(maxBuildHeight))
).build()
.tag("maxheight", Tag.inserting(Component.text(maxBuildHeight)))
.build()
);
// Return true if "failed" as the method will always be inverted otherwise
return true;
Expand Down

0 comments on commit 215053e

Please sign in to comment.