From e3c83be37e1811a0eb00ab3593991ea28c2142e4 Mon Sep 17 00:00:00 2001 From: okamosy Date: Sat, 20 Jul 2013 21:27:47 +0100 Subject: Refactored and cleaned up SpawnMob. Added context-aware help /spawnmob : --- .../src/com/earth2me/essentials/MobData.java | 349 +++++++++++++++++++++ .../src/com/earth2me/essentials/SpawnMob.java | 323 +++---------------- Essentials/src/messages.properties | 1 + Essentials/src/messages_cs.properties | 1 + Essentials/src/messages_da.properties | 1 + Essentials/src/messages_de.properties | 1 + Essentials/src/messages_en.properties | 1 + Essentials/src/messages_es.properties | 1 + Essentials/src/messages_fi.properties | 1 + Essentials/src/messages_fr.properties | 1 + Essentials/src/messages_it.properties | 1 + Essentials/src/messages_nl.properties | 1 + Essentials/src/messages_pl.properties | 1 + Essentials/src/messages_pt.properties | 1 + Essentials/src/messages_ro.properties | 1 + Essentials/src/messages_sv.properties | 1 + Essentials/src/messages_zh.properties | 1 + Essentials/src/messages_zh_HK.properties | 1 + Essentials/src/messages_zh_TW.properties | 1 + 19 files changed, 412 insertions(+), 277 deletions(-) create mode 100644 Essentials/src/com/earth2me/essentials/MobData.java diff --git a/Essentials/src/com/earth2me/essentials/MobData.java b/Essentials/src/com/earth2me/essentials/MobData.java new file mode 100644 index 000000000..bb8c13bde --- /dev/null +++ b/Essentials/src/com/earth2me/essentials/MobData.java @@ -0,0 +1,349 @@ +package com.earth2me.essentials; + +import static com.earth2me.essentials.I18n._; +import java.util.*; +import java.util.logging.Logger; +import com.earth2me.essentials.utils.StringUtil; +import org.bukkit.DyeColor; +import org.bukkit.Material; +import org.bukkit.entity.Ageable; +import org.bukkit.entity.Creeper; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.ExperienceOrb; +import org.bukkit.entity.Horse; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Ocelot; +import org.bukkit.entity.Pig; +import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton; +import org.bukkit.entity.Slime; +import org.bukkit.entity.Tameable; +import org.bukkit.entity.Villager; +import org.bukkit.entity.Wolf; +import org.bukkit.entity.Zombie; +import org.bukkit.inventory.EntityEquipment; +import org.bukkit.inventory.ItemStack; +import org.bukkit.material.Colorable; + + +public enum MobData +{ + BABY_AGEABLE("baby", Ageable.class, Data.BABY, true), + BABY_PIG("piglet", EntityType.PIG, Data.BABY, false), + BABY_WOLF("puppy", EntityType.WOLF, Data.BABY, false), + BABY_CHICKEN("chick", EntityType.CHICKEN, Data.BABY, false), + BABY_HORSE("colt", EntityType.HORSE, Data.BABY, false), + BABY_OCELOT("kitten", EntityType.OCELOT, Data.BABY, false), + BABY_SHEEP("lamb", EntityType.SHEEP, Data.BABY, false), + BABY_COW("calf", EntityType.COW.getEntityClass(), Data.BABY, false), + BABY_VILLAGER("child", EntityType.VILLAGER, Data.BABY, false), + + TAMED_TAMEABLE("tamed", Tameable.class, Data.TAMED, true), + TAME_TAMEABLE("tame", Tameable.class, Data.TAMED, false), + + RANDOM_SHEEP("random", EntityType.SHEEP, Data.COLORABLE, true), + COLORABLE_SHEEP("", StringUtil.joinList(DyeColor.values()).toLowerCase(Locale.ENGLISH), EntityType.SHEEP, Data.COLORABLE, true), + + DONKEY_HORSE("donkey", EntityType.HORSE, Horse.Variant.DONKEY, true), + MULE_HORSE("mule", EntityType.HORSE, Horse.Variant.MULE, true), + SKELETON_HORSE("skeleton", EntityType.HORSE, Horse.Variant.SKELETON_HORSE, true), + UNDEAD_HORSE("undead", EntityType.HORSE, Horse.Variant.UNDEAD_HORSE, true), + ZOMBIE_HORSE("zombie", EntityType.HORSE, Horse.Variant.UNDEAD_HORSE, false), + POLKA_HORSE("polka", EntityType.HORSE, Horse.Style.BLACK_DOTS, true), + SOOTY_HORSE("sooty", EntityType.HORSE, Horse.Style.BLACK_DOTS, false), + BLAZE_HORSE("blaze", EntityType.HORSE, Horse.Style.WHITE, true), + SOCKS_HORSE("socks", EntityType.HORSE, Horse.Style.WHITE, false), + LEOPARD_HORSE("leopard", EntityType.HORSE, Horse.Style.WHITE_DOTS, true), + APPALOOSA_HORSE("appaloosa", EntityType.HORSE, Horse.Style.WHITE_DOTS, false), + PAINT_HORSE("paint", EntityType.HORSE, Horse.Style.WHITEFIELD, true), + MILKY_HORSE("milky", EntityType.HORSE, Horse.Style.WHITEFIELD, false), + SPLOTCHY_HORSE("splotchy", EntityType.HORSE, Horse.Style.WHITEFIELD, false), + BLACK_HORSE("black", EntityType.HORSE, Horse.Color.BLACK, true), + CHESTNUT_HORSE("chestnut", EntityType.HORSE, Horse.Color.CHESTNUT, true), + LIVER_HORSE("liver", EntityType.HORSE, Horse.Color.CHESTNUT, false), + CREAMY_HORSE("creamy", EntityType.HORSE, Horse.Color.CREAMY, true), + FLAXEN_HORSE("flaxen", EntityType.HORSE, Horse.Color.CREAMY, false), + GRAY_HORSE("gray", EntityType.HORSE, Horse.Color.GRAY, true), + DAPPLE_HORSE("dapple", EntityType.HORSE, Horse.Color.GRAY, false), + BUCKSKIN_HORSE("buckskin", EntityType.HORSE, Horse.Color.DARK_BROWN, true), + DARK_HORSE("dark", EntityType.HORSE, Horse.Color.DARK_BROWN, false), + DARKBROWN_HORSE("darkbrown", EntityType.HORSE, Horse.Color.DARK_BROWN, false), + DBROWN_HORSE("dbrown", EntityType.HORSE, Horse.Color.DARK_BROWN, false), + BAY_HORSE("bay", EntityType.HORSE, Horse.Color.BROWN, true), + BROWN_HORSE("brown", EntityType.HORSE, Horse.Color.BROWN, false), + CHEST_HORSE("chest", EntityType.HORSE, Data.CHEST, true), + SADDLE_HORSE("saddle", EntityType.HORSE, Data.HORSESADDLE, true), + GOLD_ARMOR_HORSE("goldarmor", EntityType.HORSE, Material.GOLD_BARDING, true), + DIAMOND_ARMOR_HORSE("diamondarmor", EntityType.HORSE, Material.DIAMOND_BARDING, true), + ARMOR_HORSE("armor", EntityType.HORSE, Material.IRON_BARDING, true), + + SIAMESE_CAT("siamese", EntityType.OCELOT, Ocelot.Type.SIAMESE_CAT, true), + WHITE_CAT("white", EntityType.OCELOT, Ocelot.Type.SIAMESE_CAT, false), + RED_CAT("red", EntityType.OCELOT, Ocelot.Type.RED_CAT, true), + ORANGE_CAT("orange", EntityType.OCELOT, Ocelot.Type.RED_CAT, false), + TABBY_CAT("tabby", EntityType.OCELOT, Ocelot.Type.RED_CAT, false), + BLACK_CAT("black", EntityType.OCELOT, Ocelot.Type.BLACK_CAT, true), + TUXEDO_CAT("tuxedo", EntityType.OCELOT, Ocelot.Type.BLACK_CAT, false), + + VILLAGER_ZOMBIE("villager", EntityType.ZOMBIE.getEntityClass(), Data.VILLAGER, true), + BABY_ZOMBIE("baby", EntityType.ZOMBIE.getEntityClass(), Data.BABYZOMBIE, true), + + DIAMOND_SWORD_ZOMBIE("diamondsword", EntityType.ZOMBIE.getEntityClass(), Material.DIAMOND_SWORD, true), + GOLD_SWORD_ZOMBIE("goldsword", EntityType.ZOMBIE.getEntityClass(), Material.GOLD_SWORD, true), + IRON_SWORD_ZOMBIE("ironsword", EntityType.ZOMBIE.getEntityClass(), Material.IRON_SWORD, true), + STONE_SWORD_ZOMBIE("stonesword", EntityType.ZOMBIE.getEntityClass(), Material.STONE_SWORD, false), + SWORD_ZOMBIE("sword", EntityType.ZOMBIE.getEntityClass(), Material.STONE_SWORD, true), + + DIAMOND_SWORD_SKELETON("diamondsword", EntityType.SKELETON, Material.DIAMOND_SWORD, true), + GOLD_SWORD_SKELETON("goldsword", EntityType.SKELETON, Material.GOLD_SWORD, true), + IRON_SWORD_SKELETON("ironsword", EntityType.SKELETON, Material.IRON_SWORD, true), + STONE_SWORD_SKELETON("stonesword", EntityType.SKELETON, Material.STONE_SWORD, false), + SWORD_SKELETON("sword", EntityType.SKELETON, Material.STONE_SWORD, true), + WHITHER_SKELETON("wither", EntityType.SKELETON, Data.WITHER, true), + + POWERED_CREEPER("powered", EntityType.CREEPER, Data.ELECTRIFIED, true), + ELECTRIC_CREEPER("electric", EntityType.CREEPER, Data.ELECTRIFIED, false), + CHARGED_CREEPER("charged", EntityType.CREEPER, Data.ELECTRIFIED, false), + + SADDLE_PIG("saddle", EntityType.PIG, Data.PIGSADDLE, true), + + ANGRY_WOLF("angry", EntityType.WOLF, Data.ANGRY, true), + RABID_WOLF("rabid", EntityType.WOLF, Data.ANGRY, false), + + FARMER_VILLAGER("farmer", EntityType.VILLAGER, Villager.Profession.FARMER, true), + LIBRARIAN_VILLAGER("librarian", EntityType.VILLAGER, Villager.Profession.LIBRARIAN, true), + PRIEST_VILLAGER("priest", EntityType.VILLAGER, Villager.Profession.PRIEST, true), + FATHER_VILLAGER("father", EntityType.VILLAGER, Villager.Profession.PRIEST, false), + SMITH_VILLAGER("smith", EntityType.VILLAGER, Villager.Profession.BLACKSMITH, true), + BUTCHER_VILLAGER("butcher", EntityType.VILLAGER, Villager.Profession.BUTCHER, true), + + SIZE_SLIME("", "<1-100>", EntityType.SLIME.getEntityClass(), Data.SIZE, true), + NUM_EXPERIENCE_ORB("", "<1-2000000000>", EntityType.EXPERIENCE_ORB, Data.EXP, true); + + public enum Data + { + BABY, + CHEST, + BABYZOMBIE, + VILLAGER, + HORSESADDLE, + PIGSADDLE, + ELECTRIFIED, + WITHER, + ANGRY, + TAMED, + COLORABLE, + EXP, + SIZE; + } + public static final Logger logger = Logger.getLogger("Minecraft"); + + private MobData(String n, Object type, Object value, boolean isPublic) + { + this.nickname = n; + this.matched = n; + this.helpMessage = n; + this.type = type; + this.value = value; + this.isPublic = isPublic; + } + + private MobData(String n, String h, Object type, Object value, boolean isPublic) + { + this.nickname = n; + this.matched = n; + this.helpMessage = h; + this.type = type; + this.value = value; + this.isPublic = isPublic; + } + + final private String nickname; + final private String helpMessage; + final private Object type; + final private Object value; + final private boolean isPublic; + + private String matched; + + public static LinkedHashMap getPossibleData(final Entity spawned, boolean publicOnly) + { + LinkedHashMap mobList = new LinkedHashMap(); + for (MobData data : MobData.values()) + { + if (data.type instanceof EntityType && spawned.getType().equals(data.type) && ((publicOnly && data.isPublic) || !publicOnly)) + { + mobList.put(data.nickname.toLowerCase(Locale.ENGLISH), data); + } + else if (data.type instanceof Class && ((Class)data.type).isAssignableFrom(spawned.getClass()) && ((publicOnly && data.isPublic) || !publicOnly)) + { + mobList.put(data.nickname.toLowerCase(Locale.ENGLISH), data); + } + } + + return mobList; + } + + public static List getValidHelp(final Entity spawned) + { + List output = new ArrayList(); + LinkedHashMap posData = getPossibleData(spawned, true); + + for (MobData data : posData.values()) + { + output.add(data.helpMessage); + } + return output; + } + + public static MobData fromData(final Entity spawned, final String name) + { + if (name.isEmpty()) + { + return null; + } + + LinkedHashMap posData = getPossibleData(spawned, false); + for (String data : posData.keySet()) + { + if (name.contains(data)) + { + return posData.get(data); + } + } + return null; + } + + public String getMatched() + { + return this.matched; + } + + public void setData(final Entity spawned, final Player target, final String rawData) throws Exception + { + if (this.value.equals(Data.ANGRY)) + { + ((Wolf)spawned).setAngry(true); + } + else if (this.value.equals(Data.BABY)) + { + ((Ageable)spawned).setBaby(); + } + else if (this.value.equals(Data.BABYZOMBIE)) + { + ((Zombie)spawned).setBaby(true); + } + else if (this.value.equals(Data.CHEST)) + { + ((Horse)spawned).setTamed(true); + ((Horse)spawned).setCarryingChest(true); + } + else if (this.value.equals(Data.ELECTRIFIED)) + { + ((Creeper)spawned).setPowered(true); + } + else if (this.value.equals(Data.HORSESADDLE)) + { + ((Horse)spawned).setTamed(true); + ((Horse)spawned).getInventory().setSaddle(new ItemStack(Material.SADDLE, 1)); + } + else if (this.value.equals(Data.PIGSADDLE)) + { + ((Pig)spawned).setSaddle(true); + } + else if (this.value.equals(Data.TAMED)) + { + final Tameable tameable = ((Tameable)spawned); + tameable.setTamed(true); + tameable.setOwner(target); + } + else if (this.value.equals(Data.VILLAGER)) + { + ((Zombie)spawned).setVillager(this.value.equals(Data.VILLAGER)); + } + else if (this.value.equals(Data.WITHER)) + { + ((Skeleton)spawned).setSkeletonType(Skeleton.SkeletonType.WITHER); + } + else if (this.value.equals(Data.COLORABLE)) + { + final String color = rawData.toUpperCase(Locale.ENGLISH); + try + { + if (color.equals("RANDOM")) + { + final Random rand = new Random(); + ((Colorable)spawned).setColor(DyeColor.values()[rand.nextInt(DyeColor.values().length)]); + } + else if (!color.isEmpty()) + { + ((Colorable)spawned).setColor(DyeColor.valueOf(color)); + } + this.matched = rawData; + } + catch (Exception e) + { + throw new Exception(_("sheepMalformedColor"), e); + } + } + else if (this.value.equals(Data.EXP)) + { + try + { + ((ExperienceOrb)spawned).setExperience(Integer.parseInt(rawData)); + this.matched = rawData; + } + catch (Exception e) + { + throw new Exception(_("invalidNumber"), e); + } + } + else if (this.value.equals(Data.SIZE)) + { + try + { + ((Slime)spawned).setSize(Integer.parseInt(rawData)); + this.matched = rawData; + } + catch (Exception e) + { + throw new Exception(_("slimeMalformedSize"), e); + } + } + else if (this.value instanceof Horse.Color) + { + ((Horse)spawned).setColor((Horse.Color)this.value); + } + else if (this.value instanceof Horse.Style) + { + ((Horse)spawned).setStyle((Horse.Style)this.value); + } + else if (this.value instanceof Horse.Variant) + { + ((Horse)spawned).setVariant((Horse.Variant)this.value); + } + else if (this.value instanceof Ocelot.Type) + { + ((Ocelot)spawned).setCatType((Ocelot.Type)this.value); + } + else if (this.value instanceof Villager.Profession) + { + ((Villager)spawned).setProfession((Villager.Profession)this.value); + } + else if (this.value instanceof Material) + { + if (this.type.equals(EntityType.HORSE)) + { + ((Horse)spawned).setTamed(true); + ((Horse)spawned).getInventory().setArmor(new ItemStack((Material)this.value, 1)); + } + else if (this.type.equals(EntityType.ZOMBIE.getEntityClass()) || this.type.equals(EntityType.SKELETON)) + { + final EntityEquipment invent = ((LivingEntity)spawned).getEquipment(); + invent.setItemInHand(new ItemStack((Material)this.value, 1)); + invent.setItemInHandDropChance(0.1f); + } + } + } +} \ No newline at end of file diff --git a/Essentials/src/com/earth2me/essentials/SpawnMob.java b/Essentials/src/com/earth2me/essentials/SpawnMob.java index 2c40f448f..57addefca 100644 --- a/Essentials/src/com/earth2me/essentials/SpawnMob.java +++ b/Essentials/src/com/earth2me/essentials/SpawnMob.java @@ -1,29 +1,23 @@ package com.earth2me.essentials; +import static com.earth2me.essentials.I18n._; import net.ess3.api.IEssentials; import com.earth2me.essentials.utils.StringUtil; -import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.Mob.MobException; import com.earth2me.essentials.utils.LocationUtil; -import com.earth2me.essentials.utils.NumberUtil; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Locale; -import java.util.Random; import java.util.Set; -import org.bukkit.DyeColor; import org.bukkit.Location; import org.bukkit.Material; 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.inventory.EntityEquipment; -import org.bukkit.inventory.HorseInventory; import org.bukkit.inventory.ItemStack; -import org.bukkit.material.Colorable; public class SpawnMob @@ -71,7 +65,14 @@ public class SpawnMob String[] mobDatas = mobPart.split(":"); if (mobDatas.length == 1) { - mobData.add(null); + if (mobPart.contains(":")) + { + mobData.add(""); + } + else + { + mobData.add(null); + } } else { @@ -93,12 +94,6 @@ public class SpawnMob spawnmob(ess, server, user.getBase(), user, block.getLocation(), parts, data, mobCount); } - // This method spawns a mob at loc, owned by noone - public static void spawnmob(final IEssentials ess, final Server server, final CommandSender sender, final Location loc, final List parts, final List data, int mobCount) throws Exception - { - spawnmob(ess, server, sender, null, loc, parts, data, mobCount); - } - // This method spawns a mob at target, owned by target public static void spawnmob(final IEssentials ess, final Server server, final CommandSender sender, final User target, final List parts, final List data, int mobCount) throws Exception { @@ -173,7 +168,7 @@ public class SpawnMob if (data.get(i) != null) { - changeMobData(mob.getType(), spawnedMob, data.get(i), target); + changeMobData(sender, mob.getType(), spawnedMob, data.get(i).toLowerCase(Locale.ENGLISH), target); } } @@ -186,7 +181,7 @@ public class SpawnMob if (data.get(next) != null) { - changeMobData(mMob.getType(), spawnedMount, data.get(next), target); + changeMobData(sender, mMob.getType(), spawnedMount, data.get(next).toLowerCase(Locale.ENGLISH), target); } spawnedMob.setPassenger(spawnedMount); @@ -214,47 +209,58 @@ public class SpawnMob } } - private static void changeMobData(final EntityType type, final Entity spawned, String data, final User target) throws Exception + private static void changeMobData(final CommandSender sender, final EntityType type, final Entity spawned, final String inputData, final User target) throws Exception { - data = data.toLowerCase(Locale.ENGLISH); + String data = inputData; + if (data.equals("")) + { + sender.sendMessage(_("mobDataList", StringUtil.joinList(MobData.getValidHelp(spawned)))); + } + + MobData newData = MobData.fromData(spawned, data); + while (newData != null) { + newData.setData(spawned, target.getBase(), data); + data = data.replace(newData.getMatched(), ""); + newData = MobData.fromData(spawned, data); + } + if (spawned instanceof Zombie || type == EntityType.SKELETON) { - //This should match all Living Entities but most mobs will just ignore the equipment. - if (data.contains("armor") || data.contains("armour")) + if (inputData.contains("armor") || inputData.contains("armour")) { final EntityEquipment invent = ((LivingEntity)spawned).getEquipment(); - if (data.contains("diamond")) + if (inputData.contains("diamond")) { invent.setBoots(new ItemStack(Material.DIAMOND_BOOTS, 1)); - invent.setLeggings(new ItemStack(Material.DIAMOND_BOOTS, 1)); - invent.setChestplate(new ItemStack(Material.DIAMOND_BOOTS, 1)); - invent.setHelmet(new ItemStack(Material.DIAMOND_BOOTS, 1)); + invent.setLeggings(new ItemStack(Material.DIAMOND_LEGGINGS, 1)); + invent.setChestplate(new ItemStack(Material.DIAMOND_CHESTPLATE, 1)); + invent.setHelmet(new ItemStack(Material.DIAMOND_HELMET, 1)); } - else if (data.contains("gold")) + else if (inputData.contains("gold")) { invent.setBoots(new ItemStack(Material.GOLD_BOOTS, 1)); - invent.setLeggings(new ItemStack(Material.GOLD_BOOTS, 1)); - invent.setChestplate(new ItemStack(Material.GOLD_BOOTS, 1)); - invent.setHelmet(new ItemStack(Material.GOLD_BOOTS, 1)); + invent.setLeggings(new ItemStack(Material.GOLD_LEGGINGS, 1)); + invent.setChestplate(new ItemStack(Material.GOLD_CHESTPLATE, 1)); + invent.setHelmet(new ItemStack(Material.GOLD_HELMET, 1)); } - else if (data.contains("leather")) + else if (inputData.contains("leather")) { invent.setBoots(new ItemStack(Material.LEATHER_BOOTS, 1)); - invent.setLeggings(new ItemStack(Material.LEATHER_BOOTS, 1)); - invent.setChestplate(new ItemStack(Material.LEATHER_BOOTS, 1)); - invent.setHelmet(new ItemStack(Material.LEATHER_BOOTS, 1)); + invent.setLeggings(new ItemStack(Material.LEATHER_LEGGINGS, 1)); + invent.setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE, 1)); + invent.setHelmet(new ItemStack(Material.LEATHER_HELMET, 1)); } - else if (data.contains("no")) + else if (inputData.contains("no")) { invent.clear(); } else { invent.setBoots(new ItemStack(Material.IRON_BOOTS, 1)); - invent.setLeggings(new ItemStack(Material.IRON_BOOTS, 1)); - invent.setChestplate(new ItemStack(Material.IRON_BOOTS, 1)); - invent.setHelmet(new ItemStack(Material.IRON_BOOTS, 1)); + invent.setLeggings(new ItemStack(Material.IRON_LEGGINGS, 1)); + invent.setChestplate(new ItemStack(Material.IRON_CHESTPLATE, 1)); + invent.setHelmet(new ItemStack(Material.IRON_HELMET, 1)); } invent.setBootsDropChance(0f); invent.setLeggingsDropChance(0f); @@ -263,247 +269,6 @@ public class SpawnMob } } - - if (spawned instanceof Slime) - { - try - { - ((Slime)spawned).setSize(Integer.parseInt(data)); - } - catch (Exception e) - { - throw new Exception(_("slimeMalformedSize"), e); - } - } - - if ((spawned instanceof Ageable) && data.contains("baby")) - { - ((Ageable)spawned).setBaby(); - data = data.replace("baby", ""); - } - - if (spawned instanceof Colorable) - { - final String color = data.toUpperCase(Locale.ENGLISH); - try - { - if (color.equals("RANDOM")) - { - final Random rand = new Random(); - ((Colorable)spawned).setColor(DyeColor.values()[rand.nextInt(DyeColor.values().length)]); - } - else if (color.length() > 1) - { - ((Colorable)spawned).setColor(DyeColor.valueOf(color)); - } - } - catch (Exception e) - { - 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) - { - 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") || data.contains("white")) - { - ((Ocelot)spawned).setCatType(Ocelot.Type.SIAMESE_CAT); - } - else if (data.contains("red") || data.contains("orange") || data.contains("tabby")) - { - ((Ocelot)spawned).setCatType(Ocelot.Type.RED_CAT); - } - else if (data.contains("black") || data.contains("tuxedo")) - { - ((Ocelot)spawned).setCatType(Ocelot.Type.BLACK_CAT); - } - } - - if (type == EntityType.VILLAGER) - { - for (Villager.Profession prof : Villager.Profession.values()) - { - if (data.contains(prof.toString().toLowerCase(Locale.ENGLISH))) - { - ((Villager)spawned).setProfession(prof); - } - } - } - - if (spawned instanceof Zombie) - { - if (data.contains("villager")) - { - ((Zombie)spawned).setVillager(true); - } - if (data.contains("baby")) - { - ((Zombie)spawned).setBaby(true); - } - } - - if (spawned instanceof Zombie || type == EntityType.SKELETON) - { - if (data.contains("sword")) - { - final EntityEquipment invent = ((LivingEntity)spawned).getEquipment(); - if (data.contains("diamond")) - { - invent.setItemInHand(new ItemStack(Material.DIAMOND_SWORD, 1)); - } - else if (data.contains("gold")) - { - invent.setItemInHand(new ItemStack(Material.GOLD_SWORD, 1)); - } - else if (data.contains("iron")) - { - invent.setItemInHand(new ItemStack(Material.IRON_SWORD, 1)); - } - else - { - invent.setItemInHand(new ItemStack(Material.STONE_SWORD, 1)); - } - invent.setItemInHandDropChance(0.1f); - } - } - - if (type == EntityType.SKELETON) - { - if (data.contains("wither")) - { - ((Skeleton)spawned).setSkeletonType(SkeletonType.WITHER); - } - } - - if (type == EntityType.EXPERIENCE_ORB) - { - if (NumberUtil.isInt(data)) - { - ((ExperienceOrb)spawned).setExperience(Integer.parseInt(data)); - - } - } - - if (type == EntityType.HORSE) - { - if (data.contains("donkey")) - { - ((Horse)spawned).setVariant(Horse.Variant.DONKEY); - } - else if (data.contains("mule")) - { - ((Horse)spawned).setVariant(Horse.Variant.MULE); - } - else if (data.contains("skeleton")) - { - ((Horse)spawned).setVariant(Horse.Variant.SKELETON_HORSE); - } - else if (data.contains("undead")) - { - ((Horse)spawned).setVariant(Horse.Variant.UNDEAD_HORSE); - } - - if (data.contains("polka") || data.contains("sooty")) - { - ((Horse)spawned).setStyle(Horse.Style.BLACK_DOTS); - } - else if (data.contains("socks") || data.contains("blaze")) - { - ((Horse)spawned).setStyle(Horse.Style.WHITE); - } - else if (data.contains("leopard") || data.contains("appaloosa")) - { - ((Horse)spawned).setStyle(Horse.Style.WHITE_DOTS); - } - else if (data.contains("splotchy") || data.contains("milky") || data.contains("paint")) - { - ((Horse)spawned).setStyle(Horse.Style.WHITEFIELD); - } - - if (data.contains("black")) - { - ((Horse)spawned).setColor(Horse.Color.BLACK); - } - else if (data.contains("chestnut") || data.contains("liver")) - { - ((Horse)spawned).setColor(Horse.Color.CHESTNUT); - data = data.replace("chestnut", ""); - } - else if (data.contains("creamy") || data.contains("flaxen")) - { - ((Horse)spawned).setColor(Horse.Color.CREAMY); - } - else if (data.contains("gray") || data.contains("dapple")) - { - ((Horse)spawned).setColor(Horse.Color.GRAY); - } - else if (data.contains("dark") || data.contains("darkbrown") || data.contains("dbrown") || data.contains("buckskin")) - { - ((Horse)spawned).setColor(Horse.Color.DARK_BROWN); - } - else if (data.contains("brown") || data.contains("bay")) - { - ((Horse)spawned).setColor(Horse.Color.BROWN); - } - - if (data.contains("chest")) - { - ((Horse)spawned).setTamed(true); - ((Horse)spawned).setCarryingChest(true); - } - - if (data.contains("saddle")) - { - ((Horse)spawned).setTamed(true); - ((Horse)spawned).getInventory().setSaddle(new ItemStack(Material.SADDLE, 1)); - } - - if (data.contains("armor")) - { - ((Horse)spawned).setTamed(true); - HorseInventory invent = ((Horse)spawned).getInventory(); - if (data.contains("gold")) { - invent.setArmor(new ItemStack(Material.GOLD_BARDING, 1)); - } - else if (data.contains("diamond")) - { - invent.setArmor(new ItemStack(Material.DIAMOND_BARDING, 1)); - } - else - { - invent.setArmor(new ItemStack(Material.IRON_BARDING, 1)); - } - } - } - - if (type == EntityType.PIG) - { - if (data.contains("saddle")) - { - ((Pig)spawned).setSaddle(true); - } - } } private static void defaultMobData(final EntityType type, final Entity spawned) @@ -535,5 +300,9 @@ public class SpawnMob invent.setBootsDropChance(0.0f); } + if (type == EntityType.HORSE) + { + ((Horse)spawned).setJumpStrength(1.2); + } } } diff --git a/Essentials/src/messages.properties b/Essentials/src/messages.properties index 335d096bb..57eec2d7e 100644 --- a/Essentials/src/messages.properties +++ b/Essentials/src/messages.properties @@ -523,3 +523,4 @@ totalSellableAll=\u00a7aThe total worth of all sellable items and blocks is \u00 totalSellableBlocks=\u00a7aThe total worth of all sellable blocks is \u00a7c{1}\u00a7a. radiusTooBig=\u00a74Radius is too big! Maximum radius is {0}. isIpBanned=\u00a76IP \u00a7c{0} \u00a76is banned. +mobDataList=\u00a76Valid mob data:\u00a7r {0} diff --git a/Essentials/src/messages_cs.properties b/Essentials/src/messages_cs.properties index 37b046381..14111517e 100644 --- a/Essentials/src/messages_cs.properties +++ b/Essentials/src/messages_cs.properties @@ -528,3 +528,4 @@ totalSellableAll=\u00a7aThe total worth of all sellable items and blocks is \u00 totalSellableBlocks=\u00a7aThe total worth of all sellable blocks is \u00a7c{1}\u00a7a. radiusTooBig=\u00a74Radius is too big! Maximum radius is {0}. isIpBanned=\u00a76IP \u00a7c{0} \u00a76is banned. +mobDataList=\u00a76Valid mob data:\u00a7r {0} diff --git a/Essentials/src/messages_da.properties b/Essentials/src/messages_da.properties index 037f1e77e..956d29a5e 100644 --- a/Essentials/src/messages_da.properties +++ b/Essentials/src/messages_da.properties @@ -523,3 +523,4 @@ totalSellableAll=\u00a7aThe total worth of all sellable items and blocks is \u00 totalSellableBlocks=\u00a7aThe total worth of all sellable blocks is \u00a7c{1}\u00a7a. radiusTooBig=\u00a74Radius is too big! Maximum radius is {0}. isIpBanned=\u00a76IP \u00a7c{0} \u00a76is banned. +mobDataList=\u00a76Valid mob data:\u00a7r {0} diff --git a/Essentials/src/messages_de.properties b/Essentials/src/messages_de.properties index 6422d9b62..de7b39eaf 100644 --- a/Essentials/src/messages_de.properties +++ b/Essentials/src/messages_de.properties @@ -523,3 +523,4 @@ totalSellableAll=\u00a7aThe total worth of all sellable items and blocks is \u00 totalSellableBlocks=\u00a7aThe total worth of all sellable blocks is \u00a7c{1}\u00a7a. radiusTooBig=\u00a74Radius is too big! Maximum radius is {0}. isIpBanned=\u00a76IP \u00a7c{0} \u00a76is banned. +mobDataList=\u00a76Valid mob data:\u00a7r {0} diff --git a/Essentials/src/messages_en.properties b/Essentials/src/messages_en.properties index 335d096bb..57eec2d7e 100644 --- a/Essentials/src/messages_en.properties +++ b/Essentials/src/messages_en.properties @@ -523,3 +523,4 @@ totalSellableAll=\u00a7aThe total worth of all sellable items and blocks is \u00 totalSellableBlocks=\u00a7aThe total worth of all sellable blocks is \u00a7c{1}\u00a7a. radiusTooBig=\u00a74Radius is too big! Maximum radius is {0}. isIpBanned=\u00a76IP \u00a7c{0} \u00a76is banned. +mobDataList=\u00a76Valid mob data:\u00a7r {0} diff --git a/Essentials/src/messages_es.properties b/Essentials/src/messages_es.properties index ccd303a6d..c4b154c26 100644 --- a/Essentials/src/messages_es.properties +++ b/Essentials/src/messages_es.properties @@ -523,3 +523,4 @@ totalSellableAll=\u00a7aThe total worth of all sellable items and blocks is \u00 totalSellableBlocks=\u00a7aThe total worth of all sellable blocks is \u00a7c{1}\u00a7a. radiusTooBig=\u00a74Radius is too big! Maximum radius is {0}. isIpBanned=\u00a76IP \u00a7c{0} \u00a76is banned. +mobDataList=\u00a76Valid mob data:\u00a7r {0} diff --git a/Essentials/src/messages_fi.properties b/Essentials/src/messages_fi.properties index 6a58c97cf..3f49ea413 100644 --- a/Essentials/src/messages_fi.properties +++ b/Essentials/src/messages_fi.properties @@ -523,3 +523,4 @@ totalSellableAll=\u00a7aThe total worth of all sellable items and blocks is \u00 totalSellableBlocks=\u00a7aThe total worth of all sellable blocks is \u00a7c{1}\u00a7a. radiusTooBig=\u00a74Radius is too big! Maximum radius is {0}. isIpBanned=\u00a76IP \u00a7c{0} \u00a76is banned. +mobDataList=\u00a76Valid mob data:\u00a7r {0} diff --git a/Essentials/src/messages_fr.properties b/Essentials/src/messages_fr.properties index 10c957b99..b516bca16 100644 --- a/Essentials/src/messages_fr.properties +++ b/Essentials/src/messages_fr.properties @@ -523,3 +523,4 @@ totalSellableAll=\u00a7aThe total worth of all sellable items and blocks is \u00 totalSellableBlocks=\u00a7aThe total worth of all sellable blocks is \u00a7c{1}\u00a7a. radiusTooBig=\u00a74Radius is too big! Maximum radius is {0}. isIpBanned=\u00a76IP \u00a7c{0} \u00a76is banned. +mobDataList=\u00a76Valid mob data:\u00a7r {0} diff --git a/Essentials/src/messages_it.properties b/Essentials/src/messages_it.properties index 63304925c..0ed326557 100644 --- a/Essentials/src/messages_it.properties +++ b/Essentials/src/messages_it.properties @@ -523,3 +523,4 @@ totalSellableAll=\u00a7aThe total worth of all sellable items and blocks is \u00 totalSellableBlocks=\u00a7aThe total worth of all sellable blocks is \u00a7c{1}\u00a7a. radiusTooBig=\u00a74Radius is too big! Maximum radius is {0}. isIpBanned=\u00a76IP \u00a7c{0} \u00a76is banned. +mobDataList=\u00a76Valid mob data:\u00a7r {0} diff --git a/Essentials/src/messages_nl.properties b/Essentials/src/messages_nl.properties index 4832bb886..e18266287 100644 --- a/Essentials/src/messages_nl.properties +++ b/Essentials/src/messages_nl.properties @@ -523,3 +523,4 @@ totalSellableAll=\u00a7aThe total worth of all sellable items and blocks is \u00 totalSellableBlocks=\u00a7aThe total worth of all sellable blocks is \u00a7c{1}\u00a7a. radiusTooBig=\u00a74Radius is too big! Maximum radius is {0}. isIpBanned=\u00a76IP \u00a7c{0} \u00a76is banned. +mobDataList=\u00a76Valid mob data:\u00a7r {0} diff --git a/Essentials/src/messages_pl.properties b/Essentials/src/messages_pl.properties index f966e5392..c0a10322e 100644 --- a/Essentials/src/messages_pl.properties +++ b/Essentials/src/messages_pl.properties @@ -523,3 +523,4 @@ totalSellableAll=\u00a7aThe total worth of all sellable items and blocks is \u00 totalSellableBlocks=\u00a7aThe total worth of all sellable blocks is \u00a7c{1}\u00a7a. radiusTooBig=\u00a74Radius is too big! Maximum radius is {0}. isIpBanned=\u00a76IP \u00a7c{0} \u00a76is banned. +mobDataList=\u00a76Valid mob data:\u00a7r {0} diff --git a/Essentials/src/messages_pt.properties b/Essentials/src/messages_pt.properties index 640e54777..4f83f2d8a 100644 --- a/Essentials/src/messages_pt.properties +++ b/Essentials/src/messages_pt.properties @@ -523,3 +523,4 @@ totalSellableAll=\u00a7aThe total worth of all sellable items and blocks is \u00 totalSellableBlocks=\u00a7aThe total worth of all sellable blocks is \u00a7c{1}\u00a7a. radiusTooBig=\u00a74Radius is too big! Maximum radius is {0}. isIpBanned=\u00a76IP \u00a7c{0} \u00a76is banned. +mobDataList=\u00a76Valid mob data:\u00a7r {0} diff --git a/Essentials/src/messages_ro.properties b/Essentials/src/messages_ro.properties index c1798a532..d0faa6d8e 100644 --- a/Essentials/src/messages_ro.properties +++ b/Essentials/src/messages_ro.properties @@ -523,3 +523,4 @@ totalSellableAll=\u00a7aThe total worth of all sellable items and blocks is \u00 totalSellableBlocks=\u00a7aThe total worth of all sellable blocks is \u00a7c{1}\u00a7a. radiusTooBig=\u00a74Radius is too big! Maximum radius is {0}. isIpBanned=\u00a76IP \u00a7c{0} \u00a76is banned. +mobDataList=\u00a76Valid mob data:\u00a7r {0} diff --git a/Essentials/src/messages_sv.properties b/Essentials/src/messages_sv.properties index ea8cf27d9..0185fbdbc 100644 --- a/Essentials/src/messages_sv.properties +++ b/Essentials/src/messages_sv.properties @@ -523,3 +523,4 @@ totalSellableAll=\u00a7aThe total worth of all sellable items and blocks is \u00 totalSellableBlocks=\u00a7aThe total worth of all sellable blocks is \u00a7c{1}\u00a7a. radiusTooBig=\u00a74Radius is too big! Maximum radius is {0}. isIpBanned=\u00a76IP \u00a7c{0} \u00a76is banned. +mobDataList=\u00a76Valid mob data:\u00a7r {0} diff --git a/Essentials/src/messages_zh.properties b/Essentials/src/messages_zh.properties index c3046efd0..de33fcf5c 100644 --- a/Essentials/src/messages_zh.properties +++ b/Essentials/src/messages_zh.properties @@ -523,3 +523,4 @@ totalSellableAll=\u00a7aThe total worth of all sellable items and blocks is \u00 totalSellableBlocks=\u00a7aThe total worth of all sellable blocks is \u00a7c{1}\u00a7a. radiusTooBig=\u00a74Radius is too big! Maximum radius is {0}. isIpBanned=\u00a76IP \u00a7c{0} \u00a76is banned. +mobDataList=\u00a76Valid mob data:\u00a7r {0} diff --git a/Essentials/src/messages_zh_HK.properties b/Essentials/src/messages_zh_HK.properties index b2bbfaf57..ce70bc0ed 100644 --- a/Essentials/src/messages_zh_HK.properties +++ b/Essentials/src/messages_zh_HK.properties @@ -523,3 +523,4 @@ totalSellableAll=\u00a7aThe total worth of all sellable items and blocks is \u00 totalSellableBlocks=\u00a7aThe total worth of all sellable blocks is \u00a7c{1}\u00a7a. radiusTooBig=\u00a74Radius is too big! Maximum radius is {0}. isIpBanned=\u00a76IP \u00a7c{0} \u00a76is banned. +mobDataList=\u00a76Valid mob data:\u00a7r {0} diff --git a/Essentials/src/messages_zh_TW.properties b/Essentials/src/messages_zh_TW.properties index 396a17999..26c549387 100644 --- a/Essentials/src/messages_zh_TW.properties +++ b/Essentials/src/messages_zh_TW.properties @@ -523,3 +523,4 @@ totalSellableAll=\u00a7aThe total worth of all sellable items and blocks is \u00 totalSellableBlocks=\u00a7aThe total worth of all sellable blocks is \u00a7c{1}\u00a7a. radiusTooBig=\u00a74Radius is too big! Maximum radius is {0}. isIpBanned=\u00a76IP \u00a7c{0} \u00a76is banned. +mobDataList=\u00a76Valid mob data:\u00a7r {0} -- cgit v1.2.3