Handle null EntityTypes from SpawnEggs.

Fixes WORLDGUARD-3179.
This commit is contained in:
sk89q 2014-11-11 00:02:54 -08:00
parent 41f520845a
commit df985013eb

View File

@ -836,7 +836,11 @@ private static <T extends Event & Cancellable> void handleBlockRightClick(T even
if (item != null && item.getType() == Material.MONSTER_EGG) {
MaterialData data = item.getData();
if (data instanceof SpawnEgg) {
Events.fireToCancel(event, new SpawnEntityEvent(event, cause, placed.getLocation().add(0.5, 0, 0.5), ((SpawnEgg) data).getSpawnedType()));
@Nullable EntityType type = ((SpawnEgg) data).getSpawnedType();
if (type == null) {
type = EntityType.SHEEP; // Haven't investigated why it's sometimes null
}
Events.fireToCancel(event, new SpawnEntityEvent(event, cause, placed.getLocation().add(0.5, 0, 0.5), type));
}
}