From b5542e24b187393e54665cb6691b249b983d9d18 Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 15 Sep 2020 00:05:51 -0400 Subject: [PATCH] Fix NPE in admin claims (#1011) --- .../me/ryanhamshire/GriefPrevention/BlockEventHandler.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/me/ryanhamshire/GriefPrevention/BlockEventHandler.java b/src/main/java/me/ryanhamshire/GriefPrevention/BlockEventHandler.java index c6ad92b..268f320 100644 --- a/src/main/java/me/ryanhamshire/GriefPrevention/BlockEventHandler.java +++ b/src/main/java/me/ryanhamshire/GriefPrevention/BlockEventHandler.java @@ -69,6 +69,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; import java.util.List; +import java.util.Objects; import java.util.UUID; //event handlers related to blocks @@ -516,7 +517,7 @@ public class BlockEventHandler implements Listener { Block invadedBlock = pistonBlock.getRelative(direction); Claim invadedClaim = this.dataStore.getClaimAt(invadedBlock.getLocation(), false, pistonClaim); - if (invadedClaim != null && (pistonClaim == null || !pistonClaim.ownerID.equals(invadedClaim.ownerID))) + if (invadedClaim != null && (pistonClaim == null || !Objects.equals(pistonClaim.ownerID, invadedClaim.ownerID))) { event.setCancelled(true); } @@ -601,7 +602,7 @@ public class BlockEventHandler implements Listener continue; // If owners are different, cancel. - if (pistonClaim == null || !pistonClaim.ownerID.equals(claim.ownerID)) + if (pistonClaim == null || !Objects.equals(pistonClaim.ownerID, claim.ownerID)) { event.setCancelled(true); return; @@ -648,7 +649,7 @@ public class BlockEventHandler implements Listener lastClaim = claim; // If pushing this block will change ownership, cancel the event and take away the piston (for performance reasons). - if (pistonClaim == null || !pistonClaim.ownerID.equals(claim.ownerID)) + if (pistonClaim == null || !Objects.equals(pistonClaim.ownerID, claim.ownerID)) { event.setCancelled(true); pistonBlock.getWorld().createExplosion(pistonBlock.getLocation(), 0);