summaryrefslogtreecommitdiffstats
path: root/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java
diff options
context:
space:
mode:
Diffstat (limited to 'Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java')
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java64
1 files changed, 40 insertions, 24 deletions
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java b/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java
index 717a578e2..c9c8a2a4b 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java
@@ -9,13 +9,13 @@ import com.earth2me.essentials.permissions.SpawnmobPermissions;
import com.earth2me.essentials.utils.LocationUtil;
import com.earth2me.essentials.utils.Util;
import java.util.HashSet;
-import java.util.Locale;
-import java.util.Random;
-import java.util.Set;
+import java.util.*;
import org.bukkit.DyeColor;
import org.bukkit.Location;
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
@@ -97,7 +97,7 @@ public class Commandspawnmob extends EssentialsCommand
}
catch (MobException e)
{
- throw new Exception(_("unableToSpawnMob"));
+ throw new Exception(_("unableToSpawnMob"), e);
}
if (mountType != null)
@@ -119,7 +119,7 @@ public class Commandspawnmob extends EssentialsCommand
}
catch (MobException e)
{
- throw new Exception(_("unableToSpawnMob"));
+ throw new Exception(_("unableToSpawnMob"), e);
}
spawnedMob.setPassenger(spawnedMount);
}
@@ -164,7 +164,7 @@ public class Commandspawnmob extends EssentialsCommand
}
catch (MobException e)
{
- throw new Exception(_("unableToSpawnMob"));
+ throw new Exception(_("unableToSpawnMob"), e);
}
spawnedMob.setPassenger(spawnedMount);
}
@@ -201,7 +201,8 @@ public class Commandspawnmob extends EssentialsCommand
private void changeMobData(final EntityType type, final Entity spawned, String data, final IUser user) throws Exception
{
data = data.toLowerCase(Locale.ENGLISH);
- if (type == EntityType.SLIME || type == EntityType.MAGMA_CUBE)
+
+ if (spawned instanceof Slime)
{
try
{
@@ -212,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)
@@ -245,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);
@@ -268,6 +259,31 @@ public class Commandspawnmob extends EssentialsCommand
{
((Ocelot)spawned).setCatType(Ocelot.Type.SIAMESE_CAT);
}
+ else if (data.contains("red"))
+ {
+ ((Ocelot)spawned).setCatType(Ocelot.Type.RED_CAT);
+ }
+ 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);
+ }
+ }
+ }
+ if (type == EntityType.OCELOT)
+ {
+ if (data.contains("siamese"))
+ {
+ ((Ocelot)spawned).setCatType(Ocelot.Type.SIAMESE_CAT);
+ }
if (data.contains("red"))
{
((Ocelot)spawned).setCatType(Ocelot.Type.RED_CAT);