From b328d5c9fc215609688fafd97ed2480d2b481d8a Mon Sep 17 00:00:00 2001 From: FireML <106587317+FireML@users.noreply.github.com> Date: Thu, 21 Mar 2024 12:10:36 +0000 Subject: [PATCH] Add Null Checks to BlockOwnerShip#clear(UUID) --- .../blockOwnerShip/BlockOwnerShip.java | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/gamingmesh/jobs/container/blockOwnerShip/BlockOwnerShip.java b/src/main/java/com/gamingmesh/jobs/container/blockOwnerShip/BlockOwnerShip.java index 2717f1d5..257fb6de 100644 --- a/src/main/java/com/gamingmesh/jobs/container/blockOwnerShip/BlockOwnerShip.java +++ b/src/main/java/com/gamingmesh/jobs/container/blockOwnerShip/BlockOwnerShip.java @@ -259,22 +259,25 @@ public class BlockOwnerShip { } public int clear(UUID uuid) { - HashMap ls = blockOwnerShips.remove(uuid); - if (ls == null) - return 0; + HashMap ls = blockOwnerShips.remove(uuid); + if (ls == null) { + return 0; + } - for (blockLoc one : ls.values()) { - one.getBlock().removeMetadata(metadataName, plugin); + for (blockLoc one : ls.values()) { + if (one.getBlock() != null) { + one.getBlock().removeMetadata(metadataName, plugin); - Map oldRecord = ownerMapByLocation.get(one.getWorldName()); - if (oldRecord != null) - oldRecord.remove(one.toVectorString()); + Map oldRecord = ownerMapByLocation.get(one.getWorldName()); + if (oldRecord != null) + oldRecord.remove(one.toVectorString()); + } + } + + return ls.size(); } - return ls.size(); - } - public int remove(UUID uuid, String location) { HashMap ls = blockOwnerShips.get(uuid); if (ls == null)