Support new skeleton and zombie types.

Also fix baby sheep colours.
This commit is contained in:
KHobbits 2012-12-16 21:39:31 +00:00
parent 28ad7b96d2
commit 00bd6a3e02

View file

@ -12,6 +12,7 @@ import org.bukkit.Server;
import org.bukkit.block.Block;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.*;
import org.bukkit.entity.Skeleton.SkeletonType;
import org.bukkit.material.Colorable;
@ -186,14 +187,16 @@ public class SpawnMob
throw new Exception(_("slimeMalformedSize"), e);
}
}
if (spawned instanceof Ageable && data.contains("baby"))
if ((spawned instanceof Ageable) && data.contains("baby"))
{
((Ageable)spawned).setBaby();
return;
data = data.replace("baby", "");
}
if (spawned instanceof Colorable)
{
final String color = data.toUpperCase(Locale.ENGLISH).replace("BABY", "");
final String color = data.toUpperCase(Locale.ENGLISH);
try
{
if (color.equals("RANDOM"))
@ -201,7 +204,7 @@ public class SpawnMob
final Random rand = new Random();
((Colorable)spawned).setColor(DyeColor.values()[rand.nextInt(DyeColor.values().length)]);
}
else
else if (color.length() > 1)
{
((Colorable)spawned).setColor(DyeColor.valueOf(color));
}
@ -211,21 +214,28 @@ public class SpawnMob
throw new Exception(_("sheepMalformedColor"), e);
}
}
if (spawned instanceof Tameable && data.contains("tamed") && target != null)
{
final Tameable tameable = ((Tameable)spawned);
tameable.setTamed(true);
tameable.setOwner(target.getBase());
data = data.replace("tamed", "");
}
if (type == EntityType.WOLF
&& data.contains("angry"))
if (type == EntityType.WOLF)
{
if (data.contains("angry"))
{
((Wolf)spawned).setAngry(true);
}
}
if (type == EntityType.CREEPER && data.contains("powered"))
{
((Creeper)spawned).setPowered(true);
}
if (type == EntityType.OCELOT)
{
if (data.contains("siamese"))
@ -241,6 +251,7 @@ public class SpawnMob
((Ocelot)spawned).setCatType(Ocelot.Type.BLACK_CAT);
}
}
if (type == EntityType.VILLAGER)
{
for (Villager.Profession prof : Villager.Profession.values())
@ -251,5 +262,26 @@ public class SpawnMob
}
}
}
if (spawned instanceof Zombie)
{
if (data.contains("villager"))
{
((Zombie)spawned).setVillager(true);
}
if (data.contains("baby"))
{
((Zombie)spawned).setBaby(true);
}
}
if (type == EntityType.SKELETON)
{
if (data.contains("wither"))
{
((Skeleton)spawned).setSkeletonType(SkeletonType.WITHER);
}
}
}
}