1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-12-01 15:03:36 +01:00

Merge pull request #1724 from FireML/ownership-npe-fix

Add more null checks to BlockOwnerShip#clear
This commit is contained in:
Zrips 2024-04-15 12:43:19 +03:00 committed by GitHub
commit 0ab6c20d21
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -266,22 +266,25 @@ public class BlockOwnerShip {
} }
public int clear(UUID uuid) { public int clear(UUID uuid) {
HashMap<String, blockLoc> ls = blockOwnerShips.remove(uuid); HashMap<String, blockLoc> ls = blockOwnerShips.remove(uuid);
if (ls == null) if (ls == null) {
return 0; return 0;
}
for (blockLoc one : ls.values()) { for (blockLoc one : ls.values()) {
one.getBlock().removeMetadata(metadataName, plugin); if (one.getBlock() != null) {
one.getBlock().removeMetadata(metadataName, plugin);
Map<String, UUID> oldRecord = ownerMapByLocation.get(one.getWorldName()); Map<String, UUID> oldRecord = ownerMapByLocation.get(one.getWorldName());
if (oldRecord != null) if (oldRecord != null)
oldRecord.remove(one.toVectorString()); oldRecord.remove(one.toVectorString());
}
}
return ls.size();
} }
return ls.size();
}
public int remove(UUID uuid, String location) { public int remove(UUID uuid, String location) {
HashMap<String, blockLoc> ls = blockOwnerShips.get(uuid); HashMap<String, blockLoc> ls = blockOwnerShips.get(uuid);
if (ls == null) if (ls == null)