Fix NPE in admin claims (#1011)

This commit is contained in:
Adam 2020-09-15 00:05:51 -04:00 committed by GitHub
parent 2048a9f31d
commit b5542e24b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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);