summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKHobbits <rob@khobbits.co.uk>2012-03-22 18:00:13 +0000
committerKHobbits <rob@khobbits.co.uk>2012-03-22 20:03:52 +0000
commit165a76d492f63c825e5e7b6490a8bb3fe7043a86 (patch)
tree5fb4eab905b9cfd406d9028719d467c76986edaa
parent3d7d4a47d95a7332699397c8d1e93439612195c9 (diff)
downloadEssentials-165a76d492f63c825e5e7b6490a8bb3fe7043a86.tar
Essentials-165a76d492f63c825e5e7b6490a8bb3fe7043a86.tar.gz
Essentials-165a76d492f63c825e5e7b6490a8bb3fe7043a86.tar.lz
Essentials-165a76d492f63c825e5e7b6490a8bb3fe7043a86.tar.xz
Essentials-165a76d492f63c825e5e7b6490a8bb3fe7043a86.zip
Add villager professions to /spawnmob
-rw-r--r--Essentials/src/com/earth2me/essentials/Essentials.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java43
2 files changed, 24 insertions, 21 deletions
diff --git a/Essentials/src/com/earth2me/essentials/Essentials.java b/Essentials/src/com/earth2me/essentials/Essentials.java
index 05e5df1aa..68f976113 100644
--- a/Essentials/src/com/earth2me/essentials/Essentials.java
+++ b/Essentials/src/com/earth2me/essentials/Essentials.java
@@ -66,7 +66,7 @@ import org.yaml.snakeyaml.error.YAMLException;
public class Essentials extends JavaPlugin implements IEssentials
{
- public static final int BUKKIT_VERSION = 2070;
+ public static final int BUKKIT_VERSION = 2098;
private static final Logger LOGGER = Logger.getLogger("Minecraft");
private transient ISettings settings;
private final transient TNTExplodeListener tntListener = new TNTExplodeListener(this);
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java b/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java
index 8d716106f..fdaa0eb9e 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java
@@ -11,6 +11,8 @@ import org.bukkit.Location;
import org.bukkit.Server;
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
@@ -199,7 +201,8 @@ public class Commandspawnmob extends EssentialsCommand
private void changeMobData(final EntityType type, final Entity spawned, String data, final User user) throws Exception
{
data = data.toLowerCase(Locale.ENGLISH);
- if (type == EntityType.SLIME || type == EntityType.MAGMA_CUBE)
+
+ if (spawned instanceof Slime)
{
try
{
@@ -210,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)
@@ -243,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);
@@ -266,14 +259,24 @@ public class Commandspawnmob extends EssentialsCommand
{
((Ocelot)spawned).setCatType(Ocelot.Type.SIAMESE_CAT);
}
- if (data.contains("red"))
+ else if (data.contains("red"))
{
((Ocelot)spawned).setCatType(Ocelot.Type.RED_CAT);
}
- if (data.contains("black"))
+ 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);
+ }
+ }
+ }
}
}