From d6756a26058a38c3755934536b3e923956804ada Mon Sep 17 00:00:00 2001 From: KHobbits Date: Sat, 1 Jun 2013 23:33:31 +0100 Subject: [PATCH] [Fix] Set some default mob data. Fixes skeletons spawning without bows. --- .../src/com/earth2me/essentials/SpawnMob.java | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/Essentials/src/com/earth2me/essentials/SpawnMob.java b/Essentials/src/com/earth2me/essentials/SpawnMob.java index 5305f6539..36a195212 100644 --- a/Essentials/src/com/earth2me/essentials/SpawnMob.java +++ b/Essentials/src/com/earth2me/essentials/SpawnMob.java @@ -10,11 +10,14 @@ 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.ItemStack; import org.bukkit.material.Colorable; @@ -161,6 +164,7 @@ public class SpawnMob { mob = Mob.fromName(parts.get(i)); spawnedMob = mob.spawn(sloc.getWorld(), server, sloc); + defaultMobData(mob.getType(), spawnedMob); if (data.get(i) != null) { @@ -173,6 +177,7 @@ public class SpawnMob { Mob mMob = Mob.fromName(parts.get(next)); spawnedMount = mMob.spawn(sloc.getWorld(), server, sloc); + defaultMobData(mMob.getType(), spawnedMount); if (data.get(next) != null) { @@ -324,4 +329,35 @@ public class SpawnMob } } } + + private static void defaultMobData(final EntityType type, final Entity spawned) + { + if (type == EntityType.SKELETON) + { + final EntityEquipment invent = ((LivingEntity)spawned).getEquipment(); + invent.setItemInHand(new ItemStack(Material.BOW, 1)); + invent.setItemInHandDropChance(0.1f); + + invent.setBoots(new ItemStack(Material.GOLD_BOOTS, 1)); + invent.setBootsDropChance(0.0f); + } + + if (type == EntityType.PIG_ZOMBIE) + { + final EntityEquipment invent = ((LivingEntity)spawned).getEquipment(); + invent.setItemInHand(new ItemStack(Material.GOLD_SWORD, 1)); + invent.setItemInHandDropChance(0.1f); + + invent.setBoots(new ItemStack(Material.GOLD_BOOTS, 1)); + invent.setBootsDropChance(0.0f); + } + + if (type == EntityType.ZOMBIE) + { + final EntityEquipment invent = ((LivingEntity)spawned).getEquipment(); + invent.setBoots(new ItemStack(Material.GOLD_BOOTS, 1)); + invent.setBootsDropChance(0.0f); + } + + } }