diff options
-rw-r--r-- | Essentials/src/com/earth2me/essentials/Essentials.java | 2 | ||||
-rw-r--r-- | Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java | 43 |
2 files changed, 24 insertions, 21 deletions
diff --git a/Essentials/src/com/earth2me/essentials/Essentials.java b/Essentials/src/com/earth2me/essentials/Essentials.java index 05e5df1aa..68f976113 100644 --- a/Essentials/src/com/earth2me/essentials/Essentials.java +++ b/Essentials/src/com/earth2me/essentials/Essentials.java @@ -66,7 +66,7 @@ import org.yaml.snakeyaml.error.YAMLException; public class Essentials extends JavaPlugin implements IEssentials { - public static final int BUKKIT_VERSION = 2070; + public static final int BUKKIT_VERSION = 2098; private static final Logger LOGGER = Logger.getLogger("Minecraft"); private transient ISettings settings; private final transient TNTExplodeListener tntListener = new TNTExplodeListener(this); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java b/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java index 8d716106f..fdaa0eb9e 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java @@ -11,6 +11,8 @@ import org.bukkit.Location; import org.bukkit.Server; import org.bukkit.block.Block; import org.bukkit.entity.*; +import org.bukkit.entity.Villager.Profession; +import org.bukkit.material.Colorable; public class Commandspawnmob extends EssentialsCommand @@ -199,7 +201,8 @@ public class Commandspawnmob extends EssentialsCommand private void changeMobData(final EntityType type, final Entity spawned, String data, final User user) throws Exception { data = data.toLowerCase(Locale.ENGLISH); - if (type == EntityType.SLIME || type == EntityType.MAGMA_CUBE) + + if (spawned instanceof Slime) { try { @@ -210,32 +213,24 @@ public class Commandspawnmob extends EssentialsCommand throw new Exception(_("slimeMalformedSize"), e); } } - if ((type == EntityType.SHEEP - || type == EntityType.COW - || type == EntityType.MUSHROOM_COW - || type == EntityType.CHICKEN - || type == EntityType.PIG - || type == EntityType.VILLAGER - || type == EntityType.OCELOT - || type == EntityType.WOLF) - && data.contains("baby")) + if (spawned instanceof Ageable && data.contains("baby")) { - ((Animals)spawned).setBaby(); + ((Ageable)spawned).setBaby(); return; } - if (type == EntityType.SHEEP) + if (spawned instanceof Colorable) { final String color = data.toUpperCase(Locale.ENGLISH).replace("BABY", ""); try { if (color.equals("RANDOM")) { - Random rand = new Random(); - ((Sheep)spawned).setColor(DyeColor.values()[rand.nextInt(DyeColor.values().length)]); + final Random rand = new Random(); + ((Colorable)spawned).setColor(DyeColor.values()[rand.nextInt(DyeColor.values().length)]); } else { - ((Sheep)spawned).setColor(DyeColor.valueOf(color)); + ((Colorable)spawned).setColor(DyeColor.valueOf(color)); } } catch (Exception e) @@ -243,9 +238,7 @@ public class Commandspawnmob extends EssentialsCommand throw new Exception(_("sheepMalformedColor"), e); } } - if ((type == EntityType.WOLF - || type == EntityType.OCELOT) - && data.contains("tamed")) + if (spawned instanceof Tameable && data.contains("tamed")) { final Tameable tameable = ((Tameable)spawned); tameable.setTamed(true); @@ -266,14 +259,24 @@ public class Commandspawnmob extends EssentialsCommand { ((Ocelot)spawned).setCatType(Ocelot.Type.SIAMESE_CAT); } - if (data.contains("red")) + else if (data.contains("red")) { ((Ocelot)spawned).setCatType(Ocelot.Type.RED_CAT); } - if (data.contains("black")) + else if (data.contains("black")) { ((Ocelot)spawned).setCatType(Ocelot.Type.BLACK_CAT); } } + if (type == EntityType.VILLAGER) + { + for (Profession prof : Villager.Profession.values()) + { + if (data.contains(prof.toString().toLowerCase(Locale.ENGLISH))) + { + ((Villager)spawned).setProfession(prof); + } + } + } } } |