Added new mobs

This commit is contained in:
snowleo 2011-11-20 14:33:17 +01:00
parent 1f6b1f4a2c
commit 293f2f7cd2
3 changed files with 21 additions and 19 deletions

View File

@ -29,8 +29,12 @@ public enum Mob
WOLF("Wolf", Enemies.NEUTRAL, CreatureType.WOLF),
CAVESPIDER("CaveSpider", Enemies.ENEMY, CreatureType.CAVE_SPIDER),
ENDERMAN("Enderman", Enemies.ENEMY, "", CreatureType.ENDERMAN),
SILVERFISH("Silverfish", Enemies.ENEMY, "", CreatureType.SILVERFISH);
SILVERFISH("Silverfish", Enemies.ENEMY, "", CreatureType.SILVERFISH),
ENDERDRAGON("EnderDragon", Enemies.ENEMY, CreatureType.ENDER_DRAGON),
VILLAGER("Villager", Enemies.FRIENDLY, CreatureType.VILLAGER),
BLAZE("Blaze", Enemies.ENEMY, CreatureType.BLAZE),
MUSHROOMCOW("MushroomCow", Enemies.FRIENDLY, CreatureType.MUSHROOM_COW);
//TODO: Snowman
public static final Logger logger = Logger.getLogger("Minecraft");
private Mob(String n, Enemies en, String s, CreatureType type)
@ -47,7 +51,6 @@ public enum Mob
this.type = en;
this.bukkitType = type;
}
public String suffix = "s";
final public String name;
final public Enemies type;
@ -58,7 +61,7 @@ public enum Mob
{
for (Mob mob : Mob.values())
{
hashMap.put(mob.name, mob);
hashMap.put(mob.name.toLowerCase(), mob);
}
}
@ -81,24 +84,26 @@ public enum Mob
NEUTRAL("neutral"),
ENEMY("enemy");
private Enemies(final String t)
private Enemies(final String type)
{
this.type = t;
this.type = type;
}
final protected String type;
}
public CreatureType getType () {
public CreatureType getType()
{
return bukkitType;
}
public static Mob fromName(final String name)
{
return hashMap.get(name.toLowerCase());
}
public static class MobException extends Exception
{
private static final long serialVersionUID = 1L;
}
public static Mob fromName(String n)
{
return hashMap.get(n);
}
}

View File

@ -34,7 +34,6 @@ public class Commandspawner extends EssentialsCommand
try
{
String name = args[0];
name = name.equalsIgnoreCase("CaveSpider") ? "CaveSpider" : name.equalsIgnoreCase("PigZombie") ? "PigZombie" : Util.capitalCase(name);
Mob mob = null;
mob = Mob.fromName(name);

View File

@ -32,7 +32,6 @@ public class Commandspawnmob extends EssentialsCommand
String[] mountparts = args[0].split(",");
String[] parts = mountparts[0].split(":");
String mobType = parts[0];
mobType = mobType.equalsIgnoreCase("CaveSpider") ? "CaveSpider" : mobType.equalsIgnoreCase("PigZombie") ? "PigZombie" : Util.capitalCase(mobType);
String mobData = null;
if (parts.length == 2)
{
@ -44,7 +43,6 @@ public class Commandspawnmob extends EssentialsCommand
{
parts = mountparts[1].split(":");
mountType = parts[0];
mountType = mountType.equalsIgnoreCase("CaveSpider") ? "CaveSpider" : mountType.equalsIgnoreCase("PigZombie") ? "PigZombie" : Util.capitalCase(mountType);
if (parts.length == 2)
{
mountData = parts[1];
@ -62,14 +60,14 @@ public class Commandspawnmob extends EssentialsCommand
{
throw new Exception(Util.i18n("invalidMob"));
}
if (ess.getSettings().getProtectPreventSpawn(mob.getType().toString().toLowerCase()))
{
throw new Exception(Util.i18n("unableToSpawnMob"));
}
final Block block = Util.getTarget(user).getBlock();
if (block == null)
if (block == null)
{
throw new Exception(Util.i18n("unableToSpawnMob"));
}
@ -92,7 +90,7 @@ public class Commandspawnmob extends EssentialsCommand
user.sendMessage(Util.i18n("invalidMob"));
return;
}
if (ess.getSettings().getProtectPreventSpawn(mobMount.getType().toString().toLowerCase()))
{
throw new Exception(Util.i18n("unableToSpawnMob"));