summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKHobbits <rob@khobbits.co.uk>2012-12-16 21:39:31 +0000
committerKHobbits <rob@khobbits.co.uk>2012-12-16 21:39:31 +0000
commit00bd6a3e02e3ad8a7a3534f5e2323409bef9ede2 (patch)
treee47b70eb87910631a44b03c20f21bbefe72b7387
parent28ad7b96d250bc2c48bce2ca54da0d2b8360c0cf (diff)
downloadEssentials-00bd6a3e02e3ad8a7a3534f5e2323409bef9ede2.tar
Essentials-00bd6a3e02e3ad8a7a3534f5e2323409bef9ede2.tar.gz
Essentials-00bd6a3e02e3ad8a7a3534f5e2323409bef9ede2.tar.lz
Essentials-00bd6a3e02e3ad8a7a3534f5e2323409bef9ede2.tar.xz
Essentials-00bd6a3e02e3ad8a7a3534f5e2323409bef9ede2.zip
Support new skeleton and zombie types.
Also fix baby sheep colours.
-rw-r--r--Essentials/src/com/earth2me/essentials/SpawnMob.java68
1 files changed, 50 insertions, 18 deletions
diff --git a/Essentials/src/com/earth2me/essentials/SpawnMob.java b/Essentials/src/com/earth2me/essentials/SpawnMob.java
index 8ea5c9492..7eb59974c 100644
--- a/Essentials/src/com/earth2me/essentials/SpawnMob.java
+++ b/Essentials/src/com/earth2me/essentials/SpawnMob.java
@@ -12,6 +12,7 @@ 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.material.Colorable;
@@ -34,20 +35,20 @@ public class SpawnMob
}
return Util.joinList(availableList);
}
-
- public static String[] mobData(final String mobString)
+
+ public static String[] mobData(final String mobString)
{
String[] returnString = new String[4];
-
+
final String[] parts = mobString.split(",");
String[] mobParts = parts[0].split(":");
-
+
returnString[0] = mobParts[0];
if (mobParts.length == 2)
{
returnString[1] = mobParts[1];
}
-
+
if (parts.length > 1)
{
String[] mountParts = parts[1].split(":");
@@ -57,8 +58,8 @@ public class SpawnMob
returnString[3] = mountParts[1];
}
}
-
- return returnString;
+
+ return returnString;
}
// This method spawns a mob where the user is looking, owned by user
@@ -71,7 +72,7 @@ public class SpawnMob
}
spawnmob(ess, server, user, user, block.getLocation(), 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 String[] Data, int mobCount) throws Exception
{
@@ -83,7 +84,7 @@ public class SpawnMob
{
spawnmob(ess, server, sender, target, target.getLocation(), Data, mobCount);
}
-
+
// This method spawns a mob at loc, owned by target
public static void spawnmob(final IEssentials ess, final Server server, final CommandSender sender, final User target, final Location loc, final String[] Data, int mobCount) throws Exception
{
@@ -91,7 +92,7 @@ public class SpawnMob
final String mobType = Data[0];
final String mobData = Data[1];
final String mountType = Data[2];
- final String mountData = Data[3];
+ final String mountData = Data[3];
Mob mob = Mob.fromName(mobType);
Mob mobMount = null;
@@ -137,7 +138,7 @@ public class SpawnMob
{
Entity spawnedMob = mob.spawn(sloc.getWorld(), server, sloc);
Entity spawnedMount = null;
-
+
if (mobMount != null)
{
spawnedMount = mobMount.spawn(sloc.getWorld(), server, sloc);
@@ -186,14 +187,16 @@ public class SpawnMob
throw new Exception(_("slimeMalformedSize"), e);
}
}
- if (spawned instanceof Ageable && data.contains("baby"))
+
+ if ((spawned instanceof Ageable) && data.contains("baby"))
{
((Ageable)spawned).setBaby();
- return;
+ data = data.replace("baby", "");
}
+
if (spawned instanceof Colorable)
{
- final String color = data.toUpperCase(Locale.ENGLISH).replace("BABY", "");
+ final String color = data.toUpperCase(Locale.ENGLISH);
try
{
if (color.equals("RANDOM"))
@@ -201,7 +204,7 @@ public class SpawnMob
final Random rand = new Random();
((Colorable)spawned).setColor(DyeColor.values()[rand.nextInt(DyeColor.values().length)]);
}
- else
+ else if (color.length() > 1)
{
((Colorable)spawned).setColor(DyeColor.valueOf(color));
}
@@ -211,21 +214,28 @@ public class SpawnMob
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
- && data.contains("angry"))
+
+ if (type == EntityType.WOLF)
{
- ((Wolf)spawned).setAngry(true);
+ 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"))
@@ -241,6 +251,7 @@ public class SpawnMob
((Ocelot)spawned).setCatType(Ocelot.Type.BLACK_CAT);
}
}
+
if (type == EntityType.VILLAGER)
{
for (Villager.Profession prof : Villager.Profession.values())
@@ -251,5 +262,26 @@ public class SpawnMob
}
}
}
+
+ if (spawned instanceof Zombie)
+ {
+ if (data.contains("villager"))
+ {
+ ((Zombie)spawned).setVillager(true);
+ }
+ if (data.contains("baby"))
+ {
+ ((Zombie)spawned).setBaby(true);
+ }
+ }
+
+ if (type == EntityType.SKELETON)
+ {
+ if (data.contains("wither"))
+ {
+ ((Skeleton)spawned).setSkeletonType(SkeletonType.WITHER);
+ }
+ }
+
}
}