mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-15 13:36:31 +00:00
EntityType instead of CreatureType
This commit is contained in:
parent
454f7d30de
commit
056303b53c
3 changed files with 42 additions and 41 deletions
|
@ -9,40 +9,40 @@ import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.entity.CreatureType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
|
||||||
public enum Mob
|
public enum Mob
|
||||||
{
|
{
|
||||||
CHICKEN("Chicken", Enemies.FRIENDLY, CreatureType.CHICKEN),
|
CHICKEN("Chicken", Enemies.FRIENDLY, EntityType.CHICKEN),
|
||||||
COW("Cow", Enemies.FRIENDLY, CreatureType.COW),
|
COW("Cow", Enemies.FRIENDLY, EntityType.COW),
|
||||||
CREEPER("Creeper", Enemies.ENEMY, CreatureType.CREEPER),
|
CREEPER("Creeper", Enemies.ENEMY, EntityType.CREEPER),
|
||||||
GHAST("Ghast", Enemies.ENEMY, CreatureType.GHAST),
|
GHAST("Ghast", Enemies.ENEMY, EntityType.GHAST),
|
||||||
GIANT("Giant", Enemies.ENEMY, CreatureType.GIANT),
|
GIANT("Giant", Enemies.ENEMY, EntityType.GIANT),
|
||||||
PIG("Pig", Enemies.FRIENDLY, CreatureType.PIG),
|
PIG("Pig", Enemies.FRIENDLY, EntityType.PIG),
|
||||||
PIGZOMB("PigZombie", Enemies.NEUTRAL, CreatureType.PIG_ZOMBIE),
|
PIGZOMB("PigZombie", Enemies.NEUTRAL, EntityType.PIG_ZOMBIE),
|
||||||
SHEEP("Sheep", Enemies.FRIENDLY, "", CreatureType.SHEEP),
|
SHEEP("Sheep", Enemies.FRIENDLY, "", EntityType.SHEEP),
|
||||||
SKELETON("Skeleton", Enemies.ENEMY, CreatureType.SKELETON),
|
SKELETON("Skeleton", Enemies.ENEMY, EntityType.SKELETON),
|
||||||
SLIME("Slime", Enemies.ENEMY, CreatureType.SLIME),
|
SLIME("Slime", Enemies.ENEMY, EntityType.SLIME),
|
||||||
SPIDER("Spider", Enemies.ENEMY, CreatureType.SPIDER),
|
SPIDER("Spider", Enemies.ENEMY, EntityType.SPIDER),
|
||||||
SQUID("Squid", Enemies.FRIENDLY, CreatureType.SQUID),
|
SQUID("Squid", Enemies.FRIENDLY, EntityType.SQUID),
|
||||||
ZOMBIE("Zombie", Enemies.ENEMY, CreatureType.ZOMBIE),
|
ZOMBIE("Zombie", Enemies.ENEMY, EntityType.ZOMBIE),
|
||||||
WOLF("Wolf", Enemies.NEUTRAL, CreatureType.WOLF),
|
WOLF("Wolf", Enemies.NEUTRAL, EntityType.WOLF),
|
||||||
CAVESPIDER("CaveSpider", Enemies.ENEMY, CreatureType.CAVE_SPIDER),
|
CAVESPIDER("CaveSpider", Enemies.ENEMY, EntityType.CAVE_SPIDER),
|
||||||
ENDERMAN("Enderman", Enemies.ENEMY, "", CreatureType.ENDERMAN),
|
ENDERMAN("Enderman", Enemies.ENEMY, "", EntityType.ENDERMAN),
|
||||||
SILVERFISH("Silverfish", Enemies.ENEMY, "", CreatureType.SILVERFISH),
|
SILVERFISH("Silverfish", Enemies.ENEMY, "", EntityType.SILVERFISH),
|
||||||
ENDERDRAGON("EnderDragon", Enemies.ENEMY, CreatureType.ENDER_DRAGON),
|
ENDERDRAGON("EnderDragon", Enemies.ENEMY, EntityType.ENDER_DRAGON),
|
||||||
VILLAGER("Villager", Enemies.FRIENDLY, CreatureType.VILLAGER),
|
VILLAGER("Villager", Enemies.FRIENDLY, EntityType.VILLAGER),
|
||||||
BLAZE("Blaze", Enemies.ENEMY, CreatureType.BLAZE),
|
BLAZE("Blaze", Enemies.ENEMY, EntityType.BLAZE),
|
||||||
MUSHROOMCOW("MushroomCow", Enemies.FRIENDLY, CreatureType.MUSHROOM_COW),
|
MUSHROOMCOW("MushroomCow", Enemies.FRIENDLY, EntityType.MUSHROOM_COW),
|
||||||
MAGMACUBE("MagmaCube", Enemies.ENEMY, CreatureType.MAGMA_CUBE),
|
MAGMACUBE("MagmaCube", Enemies.ENEMY, EntityType.MAGMA_CUBE),
|
||||||
SNOWMAN("Snowman", Enemies.FRIENDLY, "", CreatureType.SNOWMAN);
|
SNOWMAN("Snowman", Enemies.FRIENDLY, "", EntityType.SNOWMAN);
|
||||||
|
|
||||||
public static final Logger logger = Logger.getLogger("Minecraft");
|
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.suffix = s;
|
||||||
this.name = n;
|
this.name = n;
|
||||||
|
@ -50,7 +50,7 @@ public enum Mob
|
||||||
this.bukkitType = type;
|
this.bukkitType = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Mob(String n, Enemies en, CreatureType type)
|
private Mob(String n, Enemies en, EntityType type)
|
||||||
{
|
{
|
||||||
this.name = n;
|
this.name = n;
|
||||||
this.type = en;
|
this.type = en;
|
||||||
|
@ -59,7 +59,7 @@ public enum Mob
|
||||||
public String suffix = "s";
|
public String suffix = "s";
|
||||||
final public String name;
|
final public String name;
|
||||||
final public Enemies type;
|
final public Enemies type;
|
||||||
final private CreatureType bukkitType;
|
final private EntityType bukkitType;
|
||||||
private static final Map<String, Mob> hashMap = new HashMap<String, Mob>();
|
private static final Map<String, Mob> hashMap = new HashMap<String, Mob>();
|
||||||
|
|
||||||
static
|
static
|
||||||
|
@ -99,7 +99,7 @@ public enum Mob
|
||||||
final protected String type;
|
final protected String type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CreatureType getType()
|
public EntityType getType()
|
||||||
{
|
{
|
||||||
return bukkitType;
|
return bukkitType;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.block.CreatureSpawner;
|
import org.bukkit.block.CreatureSpawner;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
|
|
||||||
|
|
||||||
public class Commandspawner extends EssentialsCommand
|
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);
|
final Trade charge = new Trade("spawner-" + mob.name.toLowerCase(Locale.ENGLISH), ess);
|
||||||
charge.isAffordableFor(user);
|
charge.isAffordableFor(user);
|
||||||
((CreatureSpawner)target.getBlock().getState()).setCreatureType(mob.getType());
|
((CreatureSpawner)target.getBlock().getState()).setSpawnedType(mob.getType());
|
||||||
charge.charge(user);
|
charge.charge(user);
|
||||||
user.sendMessage(_("setSpawner", mob.name));
|
user.sendMessage(_("setSpawner", mob.name));
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
try
|
||||||
{
|
{
|
||||||
|
@ -210,18 +210,18 @@ public class Commandspawnmob extends EssentialsCommand
|
||||||
throw new Exception(_("slimeMalformedSize"), e);
|
throw new Exception(_("slimeMalformedSize"), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((type == CreatureType.SHEEP
|
if ((type == EntityType.SHEEP
|
||||||
|| type == CreatureType.COW
|
|| type == EntityType.COW
|
||||||
|| type == CreatureType.MUSHROOM_COW
|
|| type == EntityType.MUSHROOM_COW
|
||||||
|| type == CreatureType.CHICKEN
|
|| type == EntityType.CHICKEN
|
||||||
|| type == CreatureType.PIG
|
|| type == EntityType.PIG
|
||||||
|| type == CreatureType.WOLF)
|
|| type == EntityType.WOLF)
|
||||||
&& data.equalsIgnoreCase("baby"))
|
&& data.equalsIgnoreCase("baby"))
|
||||||
{
|
{
|
||||||
((Animals)spawned).setAge(-24000);
|
((Animals)spawned).setAge(-24000);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (type == CreatureType.SHEEP)
|
if (type == EntityType.SHEEP)
|
||||||
{
|
{
|
||||||
if (data.toLowerCase(Locale.ENGLISH).contains("baby"))
|
if (data.toLowerCase(Locale.ENGLISH).contains("baby"))
|
||||||
{
|
{
|
||||||
|
@ -246,7 +246,7 @@ public class Commandspawnmob extends EssentialsCommand
|
||||||
throw new Exception(_("sheepMalformedColor"), e);
|
throw new Exception(_("sheepMalformedColor"), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (type == CreatureType.WOLF
|
if (type == EntityType.WOLF
|
||||||
&& data.toLowerCase(Locale.ENGLISH).startsWith("tamed"))
|
&& data.toLowerCase(Locale.ENGLISH).startsWith("tamed"))
|
||||||
{
|
{
|
||||||
final Wolf wolf = ((Wolf)spawned);
|
final Wolf wolf = ((Wolf)spawned);
|
||||||
|
@ -258,7 +258,7 @@ public class Commandspawnmob extends EssentialsCommand
|
||||||
((Animals)spawned).setAge(-24000);
|
((Animals)spawned).setAge(-24000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (type == CreatureType.WOLF
|
if (type == EntityType.WOLF
|
||||||
&& data.toLowerCase(Locale.ENGLISH).startsWith("angry"))
|
&& data.toLowerCase(Locale.ENGLISH).startsWith("angry"))
|
||||||
{
|
{
|
||||||
((Wolf)spawned).setAngry(true);
|
((Wolf)spawned).setAngry(true);
|
||||||
|
@ -267,7 +267,7 @@ public class Commandspawnmob extends EssentialsCommand
|
||||||
((Animals)spawned).setAge(-24000);
|
((Animals)spawned).setAge(-24000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (type == CreatureType.CREEPER && data.equalsIgnoreCase("powered"))
|
if (type == EntityType.CREEPER && data.equalsIgnoreCase("powered"))
|
||||||
{
|
{
|
||||||
((Creeper)spawned).setPowered(true);
|
((Creeper)spawned).setPowered(true);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue