From 8247f78e9d2b96dac6718a2c2af0d954e872e8ce Mon Sep 17 00:00:00 2001 From: IronApollo Date: Wed, 29 Apr 2020 14:17:05 -0400 Subject: [PATCH] Override hashCode method in AbstractRegion This commit fixes the PlotSquared issue where running a PlotSquared command could result in intense lag on the main thread. This was mainly seen with running the /p info command on an extremely large plot. Since #world can be null, the uniqueness of this hashCode is not the best, but since it's essentially just a collection of BlockVector3's, I don't believe this change will break anything. If it does, please let me know! Feedback on the uniqueness of this is welcomed. --- .../java/com/sk89q/worldedit/regions/AbstractRegion.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/AbstractRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/AbstractRegion.java index 8f7423bcd..d1afac087 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/AbstractRegion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/AbstractRegion.java @@ -212,4 +212,12 @@ public abstract class AbstractRegion extends AbstractSet implement return chunks; } + @Override + public int hashCode() { + int worldHash = this.world == null ? 7 : this.world.hashCode(); + int result = worldHash ^ (worldHash >>> 32); + result = 31 * result + this.getMinimumPoint().hashCode(); + result = 31 * result + this.getMaximumPoint().hashCode(); + return result; + } }