2012-11-11 18:55:02 +00:00
|
|
|
package com.earth2me.essentials;
|
|
|
|
|
2013-07-13 15:14:39 +00:00
|
|
|
import net.ess3.api.IEssentials;
|
2013-06-08 21:31:19 +00:00
|
|
|
import com.earth2me.essentials.utils.StringUtil;
|
2012-11-11 18:55:02 +00:00
|
|
|
import static com.earth2me.essentials.I18n._;
|
|
|
|
import com.earth2me.essentials.Mob.MobException;
|
2013-06-08 21:31:19 +00:00
|
|
|
import com.earth2me.essentials.utils.LocationUtil;
|
|
|
|
import com.earth2me.essentials.utils.NumberUtil;
|
2013-03-22 21:24:11 +00:00
|
|
|
import java.util.ArrayList;
|
2012-11-11 18:55:02 +00:00
|
|
|
import java.util.HashSet;
|
2013-03-22 21:24:11 +00:00
|
|
|
import java.util.List;
|
2012-11-11 18:55:02 +00:00
|
|
|
import java.util.Locale;
|
|
|
|
import java.util.Random;
|
|
|
|
import java.util.Set;
|
|
|
|
import org.bukkit.DyeColor;
|
|
|
|
import org.bukkit.Location;
|
2013-06-01 22:33:31 +00:00
|
|
|
import org.bukkit.Material;
|
2012-11-11 18:55:02 +00:00
|
|
|
import org.bukkit.Server;
|
|
|
|
import org.bukkit.block.Block;
|
|
|
|
import org.bukkit.command.CommandSender;
|
2013-03-16 09:16:33 +00:00
|
|
|
import org.bukkit.entity.*;
|
2013-03-22 21:24:11 +00:00
|
|
|
import org.bukkit.entity.Skeleton.SkeletonType;
|
2013-06-01 22:33:31 +00:00
|
|
|
import org.bukkit.inventory.EntityEquipment;
|
|
|
|
import org.bukkit.inventory.ItemStack;
|
2012-11-11 18:55:02 +00:00
|
|
|
import org.bukkit.material.Colorable;
|
|
|
|
|
|
|
|
|
|
|
|
public class SpawnMob
|
|
|
|
{
|
|
|
|
public static String mobList(final User user)
|
|
|
|
{
|
|
|
|
final Set<String> mobList = Mob.getMobList();
|
|
|
|
final Set<String> availableList = new HashSet<String>();
|
|
|
|
for (String mob : mobList)
|
|
|
|
{
|
2013-03-10 02:04:11 +00:00
|
|
|
if (user.isAuthorized("essentials.spawnmob." + mob.toLowerCase(Locale.ENGLISH)))
|
2012-11-11 18:55:02 +00:00
|
|
|
{
|
|
|
|
availableList.add(mob);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (availableList.isEmpty())
|
|
|
|
{
|
|
|
|
availableList.add(_("none"));
|
|
|
|
}
|
2013-06-08 21:31:19 +00:00
|
|
|
return StringUtil.joinList(availableList);
|
2012-11-11 18:55:02 +00:00
|
|
|
}
|
2012-12-16 21:39:31 +00:00
|
|
|
|
2013-03-22 21:24:11 +00:00
|
|
|
public static List<String> mobParts(final String mobString)
|
2012-11-11 18:55:02 +00:00
|
|
|
{
|
2013-03-22 21:24:11 +00:00
|
|
|
String[] mobParts = mobString.split(",");
|
2012-12-16 21:39:31 +00:00
|
|
|
|
2013-03-22 21:24:11 +00:00
|
|
|
List<String> mobs = new ArrayList<String>();
|
2012-12-16 21:39:31 +00:00
|
|
|
|
2013-03-22 21:24:11 +00:00
|
|
|
for (String mobPart : mobParts)
|
2012-11-11 18:55:02 +00:00
|
|
|
{
|
2013-03-22 21:24:11 +00:00
|
|
|
String[] mobDatas = mobPart.split(":");
|
|
|
|
mobs.add(mobDatas[0]);
|
2012-11-11 18:55:02 +00:00
|
|
|
}
|
2013-03-22 21:24:11 +00:00
|
|
|
return mobs;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static List<String> mobData(final String mobString)
|
|
|
|
{
|
|
|
|
String[] mobParts = mobString.split(",");
|
|
|
|
|
|
|
|
List<String> mobData = new ArrayList<String>();
|
2012-12-16 21:39:31 +00:00
|
|
|
|
2013-03-22 21:24:11 +00:00
|
|
|
for (String mobPart : mobParts)
|
2012-11-11 18:55:02 +00:00
|
|
|
{
|
2013-03-22 21:24:11 +00:00
|
|
|
String[] mobDatas = mobPart.split(":");
|
|
|
|
if (mobDatas.length == 1)
|
2012-11-11 18:55:02 +00:00
|
|
|
{
|
2013-03-22 21:24:11 +00:00
|
|
|
mobData.add(null);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mobData.add(mobDatas[1]);
|
2012-11-11 18:55:02 +00:00
|
|
|
}
|
|
|
|
}
|
2012-12-16 21:39:31 +00:00
|
|
|
|
2013-03-22 21:24:11 +00:00
|
|
|
return mobData;
|
2012-11-11 18:55:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// This method spawns a mob where the user is looking, owned by user
|
2013-03-22 21:24:11 +00:00
|
|
|
public static void spawnmob(final IEssentials ess, final Server server, final User user, final List<String> parts, final List<String> data, int mobCount) throws Exception
|
2012-11-11 18:55:02 +00:00
|
|
|
{
|
2013-07-07 11:11:57 +00:00
|
|
|
final Block block = LocationUtil.getTarget(user.getBase()).getBlock();
|
2012-11-11 18:55:02 +00:00
|
|
|
if (block == null)
|
|
|
|
{
|
|
|
|
throw new Exception(_("unableToSpawnMob"));
|
|
|
|
}
|
2013-07-07 12:02:40 +00:00
|
|
|
spawnmob(ess, server, user.getBase(), user, block.getLocation(), parts, data, mobCount);
|
2012-11-11 18:55:02 +00:00
|
|
|
}
|
2012-12-16 21:39:31 +00:00
|
|
|
|
2012-11-11 18:55:02 +00:00
|
|
|
// This method spawns a mob at loc, owned by noone
|
2013-03-22 21:24:11 +00:00
|
|
|
public static void spawnmob(final IEssentials ess, final Server server, final CommandSender sender, final Location loc, final List<String> parts, final List<String> data, int mobCount) throws Exception
|
2012-11-11 18:55:02 +00:00
|
|
|
{
|
2013-03-22 21:24:11 +00:00
|
|
|
spawnmob(ess, server, sender, null, loc, parts, data, mobCount);
|
2012-11-11 18:55:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// This method spawns a mob at target, owned by target
|
2013-03-22 21:24:11 +00:00
|
|
|
public static void spawnmob(final IEssentials ess, final Server server, final CommandSender sender, final User target, final List<String> parts, final List<String> data, int mobCount) throws Exception
|
2012-11-11 18:55:02 +00:00
|
|
|
{
|
2013-03-22 21:24:11 +00:00
|
|
|
spawnmob(ess, server, sender, target, target.getLocation(), parts, data, mobCount);
|
2012-11-11 18:55:02 +00:00
|
|
|
}
|
2012-12-16 21:39:31 +00:00
|
|
|
|
2012-11-11 18:55:02 +00:00
|
|
|
// This method spawns a mob at loc, owned by target
|
2013-03-22 21:24:11 +00:00
|
|
|
public static void spawnmob(final IEssentials ess, final Server server, final CommandSender sender, final User target, final Location loc, final List<String> parts, final List<String> data, int mobCount) throws Exception
|
2012-11-11 18:55:02 +00:00
|
|
|
{
|
2013-06-08 21:31:19 +00:00
|
|
|
final Location sloc = LocationUtil.getSafeDestination(loc);
|
2012-11-11 18:55:02 +00:00
|
|
|
|
2013-04-30 00:03:37 +00:00
|
|
|
for (int i = 0; i < parts.size(); i++)
|
2012-11-11 18:55:02 +00:00
|
|
|
{
|
2013-03-22 21:24:11 +00:00
|
|
|
Mob mob = Mob.fromName(parts.get(i));
|
|
|
|
checkSpawnable(ess, sender, mob);
|
2012-11-11 18:55:02 +00:00
|
|
|
}
|
|
|
|
|
2013-04-30 00:03:37 +00:00
|
|
|
final int serverLimit = ess.getSettings().getSpawnMobLimit();
|
|
|
|
int effectiveLimit = serverLimit / parts.size();
|
|
|
|
|
|
|
|
if (effectiveLimit < 1)
|
|
|
|
{
|
|
|
|
effectiveLimit = 1;
|
|
|
|
while (parts.size() > serverLimit)
|
|
|
|
{
|
|
|
|
parts.remove(serverLimit);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mobCount > effectiveLimit)
|
2012-11-11 18:55:02 +00:00
|
|
|
{
|
2013-04-30 00:03:37 +00:00
|
|
|
mobCount = effectiveLimit;
|
2012-11-11 18:55:02 +00:00
|
|
|
sender.sendMessage(_("mobSpawnLimit"));
|
|
|
|
}
|
|
|
|
|
2013-03-22 21:24:11 +00:00
|
|
|
Mob mob = Mob.fromName(parts.get(0)); // Get the first mob
|
2012-11-11 18:55:02 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
for (int i = 0; i < mobCount; i++)
|
|
|
|
{
|
2013-03-22 21:24:11 +00:00
|
|
|
spawnMob(ess, server, sender, target, sloc, parts, data);
|
2012-11-11 18:55:02 +00:00
|
|
|
}
|
2013-04-30 00:03:37 +00:00
|
|
|
sender.sendMessage(mobCount * parts.size() + " " + mob.name.toLowerCase(Locale.ENGLISH) + mob.suffix + " " + _("spawned"));
|
2012-11-11 18:55:02 +00:00
|
|
|
}
|
|
|
|
catch (MobException e1)
|
|
|
|
{
|
|
|
|
throw new Exception(_("unableToSpawnMob"), e1);
|
|
|
|
}
|
|
|
|
catch (NumberFormatException e2)
|
|
|
|
{
|
|
|
|
throw new Exception(_("numberRequired"), e2);
|
|
|
|
}
|
|
|
|
catch (NullPointerException np)
|
|
|
|
{
|
|
|
|
throw new Exception(_("soloMob"), np);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-22 21:24:11 +00:00
|
|
|
private static void spawnMob(final IEssentials ess, final Server server, final CommandSender sender, final User target, final Location sloc, List<String> parts, List<String> data) throws Exception
|
2012-11-11 18:55:02 +00:00
|
|
|
{
|
2013-03-22 21:24:11 +00:00
|
|
|
Mob mob;
|
|
|
|
Entity spawnedMob = null;
|
|
|
|
Entity spawnedMount;
|
2012-12-16 21:39:31 +00:00
|
|
|
|
2013-03-22 21:24:11 +00:00
|
|
|
for (int i = 0; i < parts.size(); i++)
|
2012-11-11 18:55:02 +00:00
|
|
|
{
|
2013-03-22 21:24:11 +00:00
|
|
|
if (i == 0)
|
|
|
|
{
|
|
|
|
mob = Mob.fromName(parts.get(i));
|
|
|
|
spawnedMob = mob.spawn(sloc.getWorld(), server, sloc);
|
2013-06-01 22:33:31 +00:00
|
|
|
defaultMobData(mob.getType(), spawnedMob);
|
2013-03-22 21:24:11 +00:00
|
|
|
|
|
|
|
if (data.get(i) != null)
|
|
|
|
{
|
|
|
|
changeMobData(mob.getType(), spawnedMob, data.get(i), target);
|
|
|
|
}
|
|
|
|
}
|
2013-04-30 00:03:37 +00:00
|
|
|
|
2013-03-22 21:24:11 +00:00
|
|
|
int next = (i + 1);
|
|
|
|
if (next < parts.size()) //If it's the last mob in the list, don't set the mount
|
|
|
|
{
|
|
|
|
Mob mMob = Mob.fromName(parts.get(next));
|
|
|
|
spawnedMount = mMob.spawn(sloc.getWorld(), server, sloc);
|
2013-06-01 22:33:31 +00:00
|
|
|
defaultMobData(mMob.getType(), spawnedMount);
|
2013-03-22 21:24:11 +00:00
|
|
|
|
|
|
|
if (data.get(next) != null)
|
|
|
|
{
|
|
|
|
changeMobData(mMob.getType(), spawnedMount, data.get(next), target);
|
|
|
|
}
|
|
|
|
|
|
|
|
spawnedMob.setPassenger(spawnedMount);
|
|
|
|
|
|
|
|
spawnedMob = spawnedMount;
|
|
|
|
}
|
2012-11-11 18:55:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private static void checkSpawnable(IEssentials ess, CommandSender sender, Mob mob) throws Exception
|
|
|
|
{
|
|
|
|
if (mob == null)
|
|
|
|
{
|
|
|
|
throw new Exception(_("invalidMob"));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ess.getSettings().getProtectPreventSpawn(mob.getType().toString().toLowerCase(Locale.ENGLISH)))
|
|
|
|
{
|
|
|
|
throw new Exception(_("disabledToSpawnMob"));
|
|
|
|
}
|
|
|
|
|
2013-07-11 08:20:52 +00:00
|
|
|
if (sender instanceof Player && !ess.getUser(sender).isAuthorized("essentials.spawnmob." + mob.name.toLowerCase(Locale.ENGLISH)))
|
2012-11-11 18:55:02 +00:00
|
|
|
{
|
|
|
|
throw new Exception(_("noPermToSpawnMob"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private static void changeMobData(final EntityType type, final Entity spawned, String data, final User target) throws Exception
|
|
|
|
{
|
|
|
|
data = data.toLowerCase(Locale.ENGLISH);
|
|
|
|
|
2013-06-05 02:15:12 +00:00
|
|
|
if (spawned instanceof Zombie || type == EntityType.SKELETON)
|
2013-06-01 22:59:21 +00:00
|
|
|
{
|
|
|
|
//This should match all Living Entities but most mobs will just ignore the equipment.
|
|
|
|
if (data.contains("armor") || data.contains("armour"))
|
|
|
|
{
|
|
|
|
final EntityEquipment invent = ((LivingEntity)spawned).getEquipment();
|
|
|
|
if (data.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));
|
|
|
|
}
|
|
|
|
else if (data.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));
|
|
|
|
}
|
|
|
|
else if (data.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));
|
|
|
|
}
|
2013-06-05 02:15:12 +00:00
|
|
|
else if (data.contains("no"))
|
|
|
|
{
|
|
|
|
invent.clear();
|
|
|
|
}
|
2013-06-01 22:59:21 +00:00
|
|
|
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.setBootsDropChance(0f);
|
|
|
|
invent.setLeggingsDropChance(0f);
|
|
|
|
invent.setChestplateDropChance(0f);
|
|
|
|
invent.setHelmetDropChance(0f);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2013-06-05 02:15:12 +00:00
|
|
|
|
|
|
|
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", "");
|
|
|
|
}
|
2013-06-01 22:59:21 +00:00
|
|
|
|
2012-11-11 18:55:02 +00:00
|
|
|
if (spawned instanceof Colorable)
|
|
|
|
{
|
2012-12-16 21:39:31 +00:00
|
|
|
final String color = data.toUpperCase(Locale.ENGLISH);
|
2012-11-11 18:55:02 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
if (color.equals("RANDOM"))
|
|
|
|
{
|
|
|
|
final Random rand = new Random();
|
|
|
|
((Colorable)spawned).setColor(DyeColor.values()[rand.nextInt(DyeColor.values().length)]);
|
|
|
|
}
|
2012-12-16 21:39:31 +00:00
|
|
|
else if (color.length() > 1)
|
2012-11-11 18:55:02 +00:00
|
|
|
{
|
|
|
|
((Colorable)spawned).setColor(DyeColor.valueOf(color));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
throw new Exception(_("sheepMalformedColor"), e);
|
|
|
|
}
|
|
|
|
}
|
2012-12-16 21:39:31 +00:00
|
|
|
|
2012-11-11 18:55:02 +00:00
|
|
|
if (spawned instanceof Tameable && data.contains("tamed") && target != null)
|
|
|
|
{
|
|
|
|
final Tameable tameable = ((Tameable)spawned);
|
|
|
|
tameable.setTamed(true);
|
|
|
|
tameable.setOwner(target.getBase());
|
2012-12-16 21:39:31 +00:00
|
|
|
data = data.replace("tamed", "");
|
2012-11-11 18:55:02 +00:00
|
|
|
}
|
2012-12-16 21:39:31 +00:00
|
|
|
|
|
|
|
if (type == EntityType.WOLF)
|
2012-11-11 18:55:02 +00:00
|
|
|
{
|
2012-12-16 21:39:31 +00:00
|
|
|
if (data.contains("angry"))
|
|
|
|
{
|
|
|
|
((Wolf)spawned).setAngry(true);
|
|
|
|
}
|
2012-11-11 18:55:02 +00:00
|
|
|
}
|
2012-12-16 21:39:31 +00:00
|
|
|
|
2012-11-11 18:55:02 +00:00
|
|
|
if (type == EntityType.CREEPER && data.contains("powered"))
|
|
|
|
{
|
|
|
|
((Creeper)spawned).setPowered(true);
|
|
|
|
}
|
2012-12-16 21:39:31 +00:00
|
|
|
|
2012-11-11 18:55:02 +00:00
|
|
|
if (type == EntityType.OCELOT)
|
|
|
|
{
|
2013-02-03 13:13:36 +00:00
|
|
|
if (data.contains("siamese") || data.contains("white"))
|
2012-11-11 18:55:02 +00:00
|
|
|
{
|
|
|
|
((Ocelot)spawned).setCatType(Ocelot.Type.SIAMESE_CAT);
|
|
|
|
}
|
2013-02-03 13:13:36 +00:00
|
|
|
else if (data.contains("red") || data.contains("orange") || data.contains("tabby"))
|
2012-11-11 18:55:02 +00:00
|
|
|
{
|
|
|
|
((Ocelot)spawned).setCatType(Ocelot.Type.RED_CAT);
|
|
|
|
}
|
2013-02-03 13:13:36 +00:00
|
|
|
else if (data.contains("black") || data.contains("tuxedo"))
|
2012-11-11 18:55:02 +00:00
|
|
|
{
|
|
|
|
((Ocelot)spawned).setCatType(Ocelot.Type.BLACK_CAT);
|
|
|
|
}
|
|
|
|
}
|
2012-12-16 21:39:31 +00:00
|
|
|
|
2012-11-11 18:55:02 +00:00
|
|
|
if (type == EntityType.VILLAGER)
|
|
|
|
{
|
|
|
|
for (Villager.Profession prof : Villager.Profession.values())
|
|
|
|
{
|
|
|
|
if (data.contains(prof.toString().toLowerCase(Locale.ENGLISH)))
|
|
|
|
{
|
|
|
|
((Villager)spawned).setProfession(prof);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-12-16 21:39:31 +00:00
|
|
|
|
|
|
|
if (spawned instanceof Zombie)
|
|
|
|
{
|
|
|
|
if (data.contains("villager"))
|
|
|
|
{
|
|
|
|
((Zombie)spawned).setVillager(true);
|
|
|
|
}
|
|
|
|
if (data.contains("baby"))
|
|
|
|
{
|
|
|
|
((Zombie)spawned).setBaby(true);
|
|
|
|
}
|
|
|
|
}
|
2013-06-01 23:09:12 +00:00
|
|
|
|
|
|
|
if (spawned instanceof Zombie || type == EntityType.SKELETON)
|
2012-12-16 21:39:31 +00:00
|
|
|
{
|
2013-06-01 22:59:21 +00:00
|
|
|
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);
|
|
|
|
}
|
2012-12-16 21:39:31 +00:00
|
|
|
}
|
|
|
|
|
2013-06-01 23:09:12 +00:00
|
|
|
if (type == EntityType.SKELETON)
|
|
|
|
{
|
|
|
|
if (data.contains("wither"))
|
|
|
|
{
|
|
|
|
((Skeleton)spawned).setSkeletonType(SkeletonType.WITHER);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-09 00:40:52 +00:00
|
|
|
if (type == EntityType.EXPERIENCE_ORB)
|
|
|
|
{
|
2013-06-08 21:31:19 +00:00
|
|
|
if (NumberUtil.isInt(data))
|
2013-01-09 00:40:52 +00:00
|
|
|
{
|
|
|
|
((ExperienceOrb)spawned).setExperience(Integer.parseInt(data));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2013-07-16 22:29:53 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
2013-07-17 17:09:56 +00:00
|
|
|
|
|
|
|
if (data.contains("saddle"))
|
|
|
|
{
|
|
|
|
((Horse)spawned).setTamed(true);
|
|
|
|
((Horse)spawned).getInventory().setSaddle(new ItemStack(Material.SADDLE, 1));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (type == EntityType.PIG)
|
|
|
|
{
|
|
|
|
if (data.contains("saddle"))
|
|
|
|
{
|
|
|
|
((Pig)spawned).setSaddle(true);
|
|
|
|
}
|
2013-07-16 22:29:53 +00:00
|
|
|
}
|
2012-11-11 18:55:02 +00:00
|
|
|
}
|
2013-06-01 22:33:31 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2012-11-11 18:55:02 +00:00
|
|
|
}
|