EntityType instead of CreatureType

This commit is contained in:
snowleo 2012-03-01 17:33:09 +01:00
parent e43a62f992
commit 696b930fb2
3 changed files with 42 additions and 41 deletions

View File

@ -9,40 +9,40 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.Location;
import org.bukkit.Server;
import org.bukkit.entity.CreatureType;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
public enum Mob
{
CHICKEN("Chicken", Enemies.FRIENDLY, CreatureType.CHICKEN),
COW("Cow", Enemies.FRIENDLY, CreatureType.COW),
CREEPER("Creeper", Enemies.ENEMY, CreatureType.CREEPER),
GHAST("Ghast", Enemies.ENEMY, CreatureType.GHAST),
GIANT("Giant", Enemies.ENEMY, CreatureType.GIANT),
PIG("Pig", Enemies.FRIENDLY, CreatureType.PIG),
PIGZOMB("PigZombie", Enemies.NEUTRAL, CreatureType.PIG_ZOMBIE),
SHEEP("Sheep", Enemies.FRIENDLY, "", CreatureType.SHEEP),
SKELETON("Skeleton", Enemies.ENEMY, CreatureType.SKELETON),
SLIME("Slime", Enemies.ENEMY, CreatureType.SLIME),
SPIDER("Spider", Enemies.ENEMY, CreatureType.SPIDER),
SQUID("Squid", Enemies.FRIENDLY, CreatureType.SQUID),
ZOMBIE("Zombie", Enemies.ENEMY, CreatureType.ZOMBIE),
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),
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),
MAGMACUBE("MagmaCube", Enemies.ENEMY, CreatureType.MAGMA_CUBE),
SNOWMAN("Snowman", Enemies.FRIENDLY, "", CreatureType.SNOWMAN);
CHICKEN("Chicken", Enemies.FRIENDLY, EntityType.CHICKEN),
COW("Cow", Enemies.FRIENDLY, EntityType.COW),
CREEPER("Creeper", Enemies.ENEMY, EntityType.CREEPER),
GHAST("Ghast", Enemies.ENEMY, EntityType.GHAST),
GIANT("Giant", Enemies.ENEMY, EntityType.GIANT),
PIG("Pig", Enemies.FRIENDLY, EntityType.PIG),
PIGZOMB("PigZombie", Enemies.NEUTRAL, EntityType.PIG_ZOMBIE),
SHEEP("Sheep", Enemies.FRIENDLY, "", EntityType.SHEEP),
SKELETON("Skeleton", Enemies.ENEMY, EntityType.SKELETON),
SLIME("Slime", Enemies.ENEMY, EntityType.SLIME),
SPIDER("Spider", Enemies.ENEMY, EntityType.SPIDER),
SQUID("Squid", Enemies.FRIENDLY, EntityType.SQUID),
ZOMBIE("Zombie", Enemies.ENEMY, EntityType.ZOMBIE),
WOLF("Wolf", Enemies.NEUTRAL, EntityType.WOLF),
CAVESPIDER("CaveSpider", Enemies.ENEMY, EntityType.CAVE_SPIDER),
ENDERMAN("Enderman", Enemies.ENEMY, "", EntityType.ENDERMAN),
SILVERFISH("Silverfish", Enemies.ENEMY, "", EntityType.SILVERFISH),
ENDERDRAGON("EnderDragon", Enemies.ENEMY, EntityType.ENDER_DRAGON),
VILLAGER("Villager", Enemies.FRIENDLY, EntityType.VILLAGER),
BLAZE("Blaze", Enemies.ENEMY, EntityType.BLAZE),
MUSHROOMCOW("MushroomCow", Enemies.FRIENDLY, EntityType.MUSHROOM_COW),
MAGMACUBE("MagmaCube", Enemies.ENEMY, EntityType.MAGMA_CUBE),
SNOWMAN("Snowman", Enemies.FRIENDLY, "", EntityType.SNOWMAN);
public static final Logger logger = Logger.getLogger("Minecraft");
private Mob(String n, Enemies en, String s, CreatureType type)
private Mob(String n, Enemies en, String s, EntityType type)
{
this.suffix = s;
this.name = n;
@ -50,7 +50,7 @@ public enum Mob
this.bukkitType = type;
}
private Mob(String n, Enemies en, CreatureType type)
private Mob(String n, Enemies en, EntityType type)
{
this.name = n;
this.type = en;
@ -59,7 +59,7 @@ public enum Mob
public String suffix = "s";
final public String name;
final public Enemies type;
final private CreatureType bukkitType;
final private EntityType bukkitType;
private static final Map<String, Mob> hashMap = new HashMap<String, Mob>();
static
@ -99,7 +99,7 @@ public enum Mob
final protected String type;
}
public CreatureType getType()
public EntityType getType()
{
return bukkitType;
}

View File

@ -10,6 +10,7 @@ import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.block.CreatureSpawner;
import org.bukkit.entity.EntityType;
public class Commandspawner extends EssentialsCommand
@ -54,7 +55,7 @@ public class Commandspawner extends EssentialsCommand
}
final Trade charge = new Trade("spawner-" + mob.name.toLowerCase(Locale.ENGLISH), ess);
charge.isAffordableFor(user);
((CreatureSpawner)target.getBlock().getState()).setCreatureType(mob.getType());
((CreatureSpawner)target.getBlock().getState()).setSpawnedType(mob.getType());
charge.charge(user);
user.sendMessage(_("setSpawner", mob.name));
}

View File

@ -197,9 +197,9 @@ public class Commandspawnmob extends EssentialsCommand
}
}
private void changeMobData(final CreatureType type, final Entity spawned, final String data, final User user) throws Exception
private void changeMobData(final EntityType type, final Entity spawned, final String data, final User user) throws Exception
{
if (type == CreatureType.SLIME || type == CreatureType.MAGMA_CUBE)
if (type == EntityType.SLIME || type == EntityType.MAGMA_CUBE)
{
try
{
@ -210,18 +210,18 @@ public class Commandspawnmob extends EssentialsCommand
throw new Exception(_("slimeMalformedSize"), e);
}
}
if ((type == CreatureType.SHEEP
|| type == CreatureType.COW
|| type == CreatureType.MUSHROOM_COW
|| type == CreatureType.CHICKEN
|| type == CreatureType.PIG
|| type == CreatureType.WOLF)
if ((type == EntityType.SHEEP
|| type == EntityType.COW
|| type == EntityType.MUSHROOM_COW
|| type == EntityType.CHICKEN
|| type == EntityType.PIG
|| type == EntityType.WOLF)
&& data.equalsIgnoreCase("baby"))
{
((Animals)spawned).setAge(-24000);
return;
}
if (type == CreatureType.SHEEP)
if (type == EntityType.SHEEP)
{
if (data.toLowerCase(Locale.ENGLISH).contains("baby"))
{
@ -246,7 +246,7 @@ public class Commandspawnmob extends EssentialsCommand
throw new Exception(_("sheepMalformedColor"), e);
}
}
if (type == CreatureType.WOLF
if (type == EntityType.WOLF
&& data.toLowerCase(Locale.ENGLISH).startsWith("tamed"))
{
final Wolf wolf = ((Wolf)spawned);
@ -258,7 +258,7 @@ public class Commandspawnmob extends EssentialsCommand
((Animals)spawned).setAge(-24000);
}
}
if (type == CreatureType.WOLF
if (type == EntityType.WOLF
&& data.toLowerCase(Locale.ENGLISH).startsWith("angry"))
{
((Wolf)spawned).setAngry(true);
@ -267,7 +267,7 @@ public class Commandspawnmob extends EssentialsCommand
((Animals)spawned).setAge(-24000);
}
}
if (type == CreatureType.CREEPER && data.equalsIgnoreCase("powered"))
if (type == EntityType.CREEPER && data.equalsIgnoreCase("powered"))
{
((Creeper)spawned).setPowered(true);
}