Put a null check into IslandCache to avoid null key in map.

This commit is contained in:
tastybento 2020-01-14 17:00:54 -08:00
parent c7e0492612
commit a9a9a9adee

View File

@ -273,7 +273,9 @@ public class IslandCache {
*/
public void setOwner(@NonNull Island island, @Nullable UUID newOwnerUUID) {
island.setOwner(newOwnerUUID);
islandsByUUID.computeIfAbsent(Util.getWorld(island.getWorld()), k -> new HashMap<>()).put(newOwnerUUID, island);
if (newOwnerUUID != null) {
islandsByUUID.computeIfAbsent(Util.getWorld(island.getWorld()), k -> new HashMap<>()).put(newOwnerUUID, island);
}
islandsByLocation.put(island.getCenter(), island);
islandsById.put(island.getUniqueId(), island);
}