Fixes some NPEs

This commit is contained in:
ceze88 2023-08-21 11:30:43 +02:00
parent 420d6038ad
commit 60849751a8
3 changed files with 4 additions and 2 deletions

View File

@ -209,7 +209,7 @@ public class InteractListeners implements Listener {
if (isSpawner && item != null && XMaterial.SPAWNER == XMaterial.matchXMaterial(item)) {
PlacedSpawner spawner = this.plugin.getSpawnerManager().getSpawnerFromWorld(location);
if (spawner.getPlacedBy() == null && Settings.DISABLE_NATURAL_SPAWNERS.getBoolean()) {
if (spawner == null || (spawner.getPlacedBy() == null && Settings.DISABLE_NATURAL_SPAWNERS.getBoolean())) {
return;
}

View File

@ -609,7 +609,8 @@ public class PlacedSpawnerImpl implements PlacedSpawner {
public Data deserialize(Map<String, Object> map) {
int id = (int) map.get("id");
int spawnCount = (int) map.get("spawn_count");
UUID placedBy = UUID.fromString((String) map.get("placed_by"));
String placedByString = (String) map.get("placed_by");
UUID placedBy = placedByString != null ? UUID.fromString(placedByString) : null;
Location location = SerializedLocation.of(map);
return new PlacedSpawnerImpl(id, spawnCount, placedBy, location);
}

View File

@ -89,6 +89,7 @@ public class SpawnerManagerImpl implements SpawnerManager {
@Override
public SpawnerData getSpawnerData(EntityType type) {
if (type == null) return null; //TODO fix this. Not sure why this is happening.
return getSpawnerData(type.name());
}