From 422cba101de2e7e486b1a737be62aa2b93db1634 Mon Sep 17 00:00:00 2001 From: wizjany Date: Sun, 17 Mar 2013 22:11:29 -0400 Subject: [PATCH] Fix NPE in mob spawner blocks on non-bukkit implementations --- .../worldedit/blocks/MobSpawnerBlock.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/sk89q/worldedit/blocks/MobSpawnerBlock.java b/src/main/java/com/sk89q/worldedit/blocks/MobSpawnerBlock.java index 3da4c1358..32e4ed2fe 100644 --- a/src/main/java/com/sk89q/worldedit/blocks/MobSpawnerBlock.java +++ b/src/main/java/com/sk89q/worldedit/blocks/MobSpawnerBlock.java @@ -147,8 +147,8 @@ public class MobSpawnerBlock extends BaseBlock implements TileEntityBlock { values.put("MaxSpawnDelay", new ShortTag("MaxSpawnDelay", maxSpawnDelay)); values.put("MaxNearbyEntities", new ShortTag("MaxNearbyEntities", maxNearbyEntities)); values.put("RequiredPlayerRange", new ShortTag("RequiredPlayerRange", requiredPlayerRange)); - values.put("SpawnData", new CompoundTag("SpawnData", spawnData.getValue())); - values.put("SpawnPotentials", new ListTag("SpawnPotentials", CompoundTag.class, spawnPotentials.getValue())); + values.put("SpawnData", new CompoundTag("SpawnData", spawnData == null ? null : spawnData.getValue())); + values.put("SpawnPotentials", new ListTag("SpawnPotentials", CompoundTag.class, spawnPotentials == null ? null : spawnPotentials.getValue())); return new CompoundTag(getNbtId(), values); } @@ -192,14 +192,14 @@ public class MobSpawnerBlock extends BaseBlock implements TileEntityBlock { } catch (InvalidFormatException e) { // leave tag as null, handle later } - this.spawnCount = spawnCountTag.getValue(); - this.spawnRange = spawnRangeTag.getValue(); - this.minSpawnDelay = minSpawnDelayTag.getValue(); - this.maxSpawnDelay = maxSpawnDelayTag.getValue(); - this.maxNearbyEntities = maxNearbyEntitiesTag.getValue(); - this.requiredPlayerRange = requiredPlayerRangeTag.getValue(); - this.spawnPotentials = new ListTag("SpawnPotentials", CompoundTag.class, spawnPotentialsTag.getValue()); - this.spawnData = new CompoundTag("SpawnData", spawnDataTag.getValue()); + this.spawnCount = spawnCountTag == null ? null : spawnCountTag.getValue(); + this.spawnRange = spawnRangeTag == null ? null : spawnRangeTag.getValue(); + this.minSpawnDelay = minSpawnDelayTag == null ? null : minSpawnDelayTag.getValue(); + this.maxSpawnDelay = maxSpawnDelayTag == null ? null : maxSpawnDelayTag.getValue(); + this.maxNearbyEntities = maxNearbyEntitiesTag == null ? null : maxNearbyEntitiesTag.getValue(); + this.requiredPlayerRange = requiredPlayerRangeTag == null ? null : requiredPlayerRangeTag.getValue(); + this.spawnPotentials = new ListTag("SpawnPotentials", CompoundTag.class, spawnPotentialsTag == null ? null : spawnPotentialsTag.getValue()); + this.spawnData = new CompoundTag("SpawnData", spawnDataTag == null ? null : spawnDataTag.getValue()); } }