Permalink
Browse files

Fix NPE in mob spawner blocks on non-bukkit implementations

  • Loading branch information...
1 parent 2e8119b commit 422cba101de2e7e486b1a737be62aa2b93db1634 @wizjany wizjany committed Mar 18, 2013
Showing with 10 additions and 10 deletions.
  1. +10 −10 src/main/java/com/sk89q/worldedit/blocks/MobSpawnerBlock.java
@@ -147,8 +147,8 @@ public CompoundTag getNbtData() {
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 void setNbtData(CompoundTag rootTag) throws DataException {
} 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());
}
}

0 comments on commit 422cba1

Please sign in to comment.