From 0e3a2e979161327946365e71b97bbcf74f572e6b Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 5 Jan 2022 00:24:35 -0500 Subject: [PATCH] Fix new depth not being set correctly (#1736) --- .../events/ClaimExtendEvent.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/main/java/me/ryanhamshire/GriefPrevention/events/ClaimExtendEvent.java b/src/main/java/me/ryanhamshire/GriefPrevention/events/ClaimExtendEvent.java index f6ec86f..b563f8d 100644 --- a/src/main/java/me/ryanhamshire/GriefPrevention/events/ClaimExtendEvent.java +++ b/src/main/java/me/ryanhamshire/GriefPrevention/events/ClaimExtendEvent.java @@ -1,6 +1,7 @@ package me.ryanhamshire.GriefPrevention.events; import me.ryanhamshire.GriefPrevention.Claim; +import org.bukkit.Location; import org.jetbrains.annotations.NotNull; /** @@ -14,6 +15,8 @@ import org.jetbrains.annotations.NotNull; public class ClaimExtendEvent extends ClaimChangeEvent { + private int newDepth; + /** * Construct a new {@code ClaimExtendEvent}. * @@ -22,8 +25,16 @@ public class ClaimExtendEvent extends ClaimChangeEvent */ public ClaimExtendEvent(@NotNull Claim claim, int newDepth) { - super(claim, new Claim(claim)); - this.getTo().getLesserBoundaryCorner().setY(newDepth); + super(claim, new Claim(claim) { + @Override + public Location getLesserBoundaryCorner() + { + Location lesserBoundaryCorner = super.getLesserBoundaryCorner(); + lesserBoundaryCorner.setY(newDepth); + return lesserBoundaryCorner; + } + }); + this.newDepth = newDepth; } /** @@ -45,7 +56,7 @@ public class ClaimExtendEvent extends ClaimChangeEvent */ public int getNewDepth() { - return getTo().getLesserBoundaryCorner().getBlockY(); + return newDepth; } /** @@ -56,7 +67,7 @@ public class ClaimExtendEvent extends ClaimChangeEvent * @param newDepth the new depth */ public void setNewDepth(int newDepth) { - getTo().getLesserBoundaryCorner().setY(newDepth); + this.newDepth = newDepth; } }