mirror of
https://github.com/garbagemule/MobArena.git
synced 2024-11-23 11:06:14 +01:00
Convert MACreature to class.
This commit is contained in:
parent
aafeb93d38
commit
0e814b9c0f
@ -1,7 +1,9 @@
|
||||
package com.garbagemule.MobArena.waves;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Location;
|
||||
@ -14,185 +16,200 @@ import org.bukkit.inventory.ItemStack;
|
||||
import com.garbagemule.MobArena.MobArena;
|
||||
import com.garbagemule.MobArena.framework.Arena;
|
||||
|
||||
public enum MACreature
|
||||
public class MACreature
|
||||
{
|
||||
// Default creatures
|
||||
ZOMBIE(EntityType.ZOMBIE), ZOMBIES(EntityType.ZOMBIE),
|
||||
SKELETON(EntityType.SKELETON), SKELETONS(EntityType.SKELETON),
|
||||
SPIDER(EntityType.SPIDER), SPIDERS(EntityType.SPIDER),
|
||||
CREEPER(EntityType.CREEPER), CREEPERS(EntityType.CREEPER),
|
||||
WOLF(EntityType.WOLF), WOLVES(EntityType.WOLF),
|
||||
|
||||
public static final MACreature ZOMBIE = new MACreature("zombie", EntityType.ZOMBIE);
|
||||
public static final MACreature SKELETON = new MACreature("skeleton", EntityType.SKELETON);
|
||||
public static final MACreature SPIDER = new MACreature("spider", EntityType.SPIDER);
|
||||
public static final MACreature CREEPER = new MACreature("creeper", EntityType.CREEPER);
|
||||
public static final MACreature WOLF = new MACreature("wolf", "wolves", EntityType.WOLF);
|
||||
|
||||
// Special creatures
|
||||
ZOMBIEPIGMAN(EntityType.PIG_ZOMBIE), ZOMBIEPIGMEN(EntityType.PIG_ZOMBIE),
|
||||
POWEREDCREEPER(EntityType.CREEPER), POWEREDCREEPERS(EntityType.CREEPER),
|
||||
ANGRYWOLF(EntityType.WOLF), ANGRYWOLVES(EntityType.WOLF),
|
||||
GIANT(EntityType.GIANT), GIANTS(EntityType.GIANT),
|
||||
GHAST(EntityType.GHAST), GHASTS(EntityType.GHAST),
|
||||
ENDERMAN(EntityType.ENDERMAN), ENDERMEN(EntityType.ENDERMAN),
|
||||
CAVESPIDER(EntityType.CAVE_SPIDER), CAVESPIDERS(EntityType.CAVE_SPIDER),
|
||||
SILVERFISH(EntityType.SILVERFISH),
|
||||
|
||||
public static final MACreature ZOMBIEPIGMAN = new MACreature("zombiepigman", "zombiepigmen", EntityType.PIG_ZOMBIE);
|
||||
public static final MACreature POWEREDCREEPER = new MACreature("poweredcreeper", EntityType.CREEPER);
|
||||
public static final MACreature ANGRYWOLF = new MACreature("angrywolf", "angrywolves", EntityType.WOLF);
|
||||
public static final MACreature GIANT = new MACreature("giant", EntityType.GIANT);
|
||||
public static final MACreature GHAST = new MACreature("ghast", EntityType.GHAST);
|
||||
public static final MACreature ENDERMAN = new MACreature("enderman", "endermen", EntityType.ENDERMAN);
|
||||
public static final MACreature CAVESPIDER = new MACreature("cavespider", EntityType.CAVE_SPIDER);
|
||||
public static final MACreature SILVERFISH = new MACreature("silverfish", null, EntityType.SILVERFISH);
|
||||
|
||||
// 1.0 creatures
|
||||
BLAZE(EntityType.BLAZE), BLAZES(EntityType.BLAZE),
|
||||
ENDERDRAGON(EntityType.ENDER_DRAGON), ENDERDRAGONS(EntityType.ENDER_DRAGON),
|
||||
SNOWMAN(EntityType.SNOWMAN), SNOWMEN(EntityType.SNOWMAN),
|
||||
SNOWGOLEM(EntityType.SNOWMAN), SNOWGOLEMS(EntityType.SNOWMAN),
|
||||
MUSHROOMCOW(EntityType.MUSHROOM_COW), MUSHROOMCOWS(EntityType.MUSHROOM_COW),
|
||||
VILLAGER(EntityType.VILLAGER), VILLAGERS(EntityType.VILLAGER),
|
||||
|
||||
public static final MACreature BLAZE = new MACreature("blaze", EntityType.BLAZE);
|
||||
public static final MACreature ENDERDRAGON = new MACreature("enderdragon", EntityType.ENDER_DRAGON);
|
||||
public static final MACreature SNOWMAN = new MACreature("snowman", "snowmen", EntityType.SNOWMAN);
|
||||
public static final MACreature SNOWGOLEM = new MACreature("snowgolem", EntityType.SNOWMAN);
|
||||
public static final MACreature MUSHROOMCOW = new MACreature("mushroomcow", EntityType.MUSHROOM_COW);
|
||||
public static final MACreature MOOSHROOM = new MACreature("mooshroom", EntityType.MUSHROOM_COW);
|
||||
public static final MACreature VILLAGER = new MACreature("villager", EntityType.VILLAGER);
|
||||
|
||||
// 1.2 creatures
|
||||
OCELOT(EntityType.OCELOT), OCELOTS(EntityType.OCELOT),
|
||||
IRONGOLEM(EntityType.IRON_GOLEM), IRONGOLEMS(EntityType.IRON_GOLEM),
|
||||
|
||||
public static final MACreature OCELOT = new MACreature("ocelot", EntityType.OCELOT);
|
||||
public static final MACreature IRONGOLEM = new MACreature("irongolem", EntityType.IRON_GOLEM);
|
||||
|
||||
// Passive creatures
|
||||
CHICKEN(EntityType.CHICKEN), CHICKENS(EntityType.CHICKEN),
|
||||
COW(EntityType.COW), COWS(EntityType.COW),
|
||||
PIG(EntityType.PIG), PIGS(EntityType.PIG),
|
||||
SHEEP(EntityType.SHEEP),
|
||||
SQUID(EntityType.SQUID), SQUIDS(EntityType.SQUID),
|
||||
|
||||
public static final MACreature CHICKEN = new MACreature("chicken", EntityType.CHICKEN);
|
||||
public static final MACreature COW = new MACreature("cow", EntityType.COW);
|
||||
public static final MACreature PIG = new MACreature("pig", EntityType.PIG);
|
||||
public static final MACreature SHEEP = new MACreature("sheep", null, EntityType.SHEEP);
|
||||
public static final MACreature SQUID = new MACreature("squid", EntityType.SQUID);
|
||||
|
||||
// Extended creatures
|
||||
EXPLODINGSHEEP(EntityType.SHEEP),
|
||||
|
||||
public static final MACreature EXPLODINGSHEEP = new MACreature("explodingsheep", null, EntityType.SHEEP);
|
||||
|
||||
// Slimes
|
||||
SLIME(EntityType.SLIME), SLIMES(EntityType.SLIME),
|
||||
SLIMETINY(EntityType.SLIME), SLIMESTINY(EntityType.SLIME),
|
||||
SLIMESMALL(EntityType.SLIME), SLIMESSMALL(EntityType.SLIME),
|
||||
SLIMEBIG(EntityType.SLIME), SLIMESBIG(EntityType.SLIME),
|
||||
SLIMEHUGE(EntityType.SLIME), SLIMESHUGE(EntityType.SLIME),
|
||||
|
||||
public static final MACreature SLIME = new MACreature("slime", EntityType.SLIME);
|
||||
public static final MACreature SLIMETINY = new MACreature("slimetiny", "slimestiny", EntityType.SLIME);
|
||||
public static final MACreature SLIMESMALL = new MACreature("slimesmall", "slimessmall", EntityType.SLIME);
|
||||
public static final MACreature SLIMEBIG = new MACreature("slimebig", "slimesbig", EntityType.SLIME);
|
||||
public static final MACreature SLIMEHUGE = new MACreature("slimehuge", "slimeshuge", EntityType.SLIME);
|
||||
|
||||
// Magma cubes
|
||||
MAGMACUBE(EntityType.MAGMA_CUBE), MAGMACUBES(EntityType.MAGMA_CUBE),
|
||||
MAGMACUBETINY(EntityType.MAGMA_CUBE), MAGMACUBESTINY(EntityType.MAGMA_CUBE),
|
||||
MAGMACUBESMALL(EntityType.MAGMA_CUBE),MAGMACUBESSMALL(EntityType.MAGMA_CUBE),
|
||||
MAGMACUBEBIG(EntityType.MAGMA_CUBE), MAGMACUBESBIG(EntityType.MAGMA_CUBE),
|
||||
MAGMACUBEHUGE(EntityType.MAGMA_CUBE), MAGMACUBESHUGE(EntityType.MAGMA_CUBE),
|
||||
|
||||
public static final MACreature MAGMACUBE = new MACreature("magmacube", EntityType.MAGMA_CUBE);
|
||||
public static final MACreature MAGMACUBETINY = new MACreature("magmacubetiny", "magmacubestiny", EntityType.MAGMA_CUBE);
|
||||
public static final MACreature MAGMACUBESMALL = new MACreature("magmacubesmall", "magmacubessmall", EntityType.MAGMA_CUBE);
|
||||
public static final MACreature MAGMACUBEBIG = new MACreature("magmacubebig", "magmacubesbig", EntityType.MAGMA_CUBE);
|
||||
public static final MACreature MAGMACUBEHUGE = new MACreature("magmacubehuge", "magmacubeshuge", EntityType.MAGMA_CUBE);
|
||||
|
||||
// 1.4 creatures
|
||||
BAT(EntityType.BAT), BATS(EntityType.BAT),
|
||||
WITCH(EntityType.WITCH), WITCHES(EntityType.WITCH),
|
||||
WITHER(EntityType.WITHER), WITHERS(EntityType.WITHER),
|
||||
WITHERSKELETON(EntityType.SKELETON), WITHERSKELETONS(EntityType.SKELETON),
|
||||
BABYZOMBIE(EntityType.ZOMBIE), BABYZOMBIES(EntityType.ZOMBIE),
|
||||
BABYPIGMAN(EntityType.PIG_ZOMBIE), BABYPIGMEN(EntityType.PIG_ZOMBIE),
|
||||
ZOMBIEVILLAGER(EntityType.ZOMBIE), ZOMBIEVILLAGERS(EntityType.ZOMBIE),
|
||||
BABYZOMBIEVILLAGER(EntityType.ZOMBIE),BABYZOMBIEVILLAGERS(EntityType.ZOMBIE),
|
||||
public static final MACreature BAT = new MACreature("bat", EntityType.BAT);
|
||||
public static final MACreature WITCH = new MACreature("witch", "witches", EntityType.WITCH);
|
||||
public static final MACreature WITHER = new MACreature("wither", EntityType.WITHER);
|
||||
public static final MACreature WITHERSKELETON = new MACreature("witherskeleton", EntityType.SKELETON);
|
||||
public static final MACreature BABYZOMBIE = new MACreature("babyzombie", EntityType.ZOMBIE);
|
||||
public static final MACreature BABYPIGMAN = new MACreature("babypigman", "babypigmen", EntityType.PIG_ZOMBIE);
|
||||
public static final MACreature ZOMBIEVILLAGER = new MACreature("zombievillager", EntityType.ZOMBIE);
|
||||
public static final MACreature BABYZOMBIEVILLAGER = new MACreature("babyzombievillager", EntityType.ZOMBIE);
|
||||
|
||||
// 1.6 creatures
|
||||
HORSE(EntityType.HORSE), HORSES(EntityType.HORSE),
|
||||
DONKEY(EntityType.HORSE), DONKEYS(EntityType.HORSE),
|
||||
MULE(EntityType.HORSE), MULES(EntityType.HORSE),
|
||||
SKELETONHORSE(EntityType.HORSE), SKELETONHORSES(EntityType.HORSE),
|
||||
UNDEADHORSE(EntityType.HORSE), UNDEADHORSES(EntityType.HORSE);
|
||||
public static final MACreature HORSE = new MACreature("horse", EntityType.HORSE);
|
||||
public static final MACreature DONKEY = new MACreature("donkey", EntityType.HORSE);
|
||||
public static final MACreature MULE = new MACreature("mule", EntityType.HORSE);
|
||||
public static final MACreature SKELETONHORSE = new MACreature("skeletonhorse", EntityType.HORSE);
|
||||
public static final MACreature UNDEADHORSE = new MACreature("undeadhorse", EntityType.HORSE);
|
||||
|
||||
private static Map<String,MACreature> map;
|
||||
static {
|
||||
map = new HashMap<>();
|
||||
for (EntityType type : EntityType.values()) {
|
||||
// Instantiating a new creature registers it
|
||||
new MACreature(type);
|
||||
}
|
||||
}
|
||||
|
||||
private List<DyeColor> colors = Arrays.asList(DyeColor.values());
|
||||
private String name;
|
||||
private String plural;
|
||||
private EntityType type;
|
||||
|
||||
private MACreature(EntityType type) {
|
||||
|
||||
public MACreature(String name, String plural, EntityType type) {
|
||||
this.name = name;
|
||||
this.plural = (plural != null) ? plural : name;
|
||||
this.type = type;
|
||||
|
||||
register();
|
||||
}
|
||||
|
||||
public MACreature(String name, EntityType type) {
|
||||
this(name, name + "s", type);
|
||||
}
|
||||
|
||||
private MACreature(EntityType type) {
|
||||
this(
|
||||
type.name().toLowerCase().replaceAll("[-_\\.]", ""),
|
||||
type.name().toLowerCase().replaceAll("[-_\\.]", "") + "s",
|
||||
type
|
||||
);
|
||||
}
|
||||
|
||||
private void register() {
|
||||
map.put(name, this);
|
||||
map.put(plural, this);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public EntityType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public static MACreature fromString(String string) {
|
||||
return WaveUtils.getEnumFromString(MACreature.class, string.replaceAll("[-_\\.]", ""));
|
||||
return map.get(string.replaceAll("[-_\\.]", ""));
|
||||
}
|
||||
|
||||
public LivingEntity spawn(Arena arena, World world, Location loc) {
|
||||
LivingEntity e = (LivingEntity) world.spawnEntity(loc, type);
|
||||
e.getEquipment().clear();
|
||||
|
||||
switch (this) {
|
||||
case SHEEP:
|
||||
|
||||
switch (this.name) {
|
||||
case "sheep":
|
||||
((Sheep) e).setColor(colors.get(MobArena.random.nextInt(colors.size())));
|
||||
break;
|
||||
case EXPLODINGSHEEP:
|
||||
case "explodingsheep":
|
||||
arena.getMonsterManager().addExplodingSheep(e);
|
||||
((Sheep) e).setColor(DyeColor.RED);
|
||||
break;
|
||||
case POWEREDCREEPERS:
|
||||
case "poweredcreeper":
|
||||
((Creeper) e).setPowered(true);
|
||||
break;
|
||||
case ANGRYWOLVES:
|
||||
case "angrywolf":
|
||||
((Wolf) e).setAngry(true);
|
||||
break;
|
||||
case SLIME:
|
||||
case SLIMES:
|
||||
case MAGMACUBE:
|
||||
case MAGMACUBES:
|
||||
case "slime":
|
||||
case "magmacube":
|
||||
((Slime) e).setSize( (1 + MobArena.random.nextInt(3)) );
|
||||
break;
|
||||
case SLIMETINY:
|
||||
case SLIMESTINY:
|
||||
case MAGMACUBETINY:
|
||||
case MAGMACUBESTINY:
|
||||
case "slimetiny":
|
||||
case "magmacubetiny":
|
||||
((Slime) e).setSize(1);
|
||||
break;
|
||||
case SLIMESMALL:
|
||||
case SLIMESSMALL:
|
||||
case MAGMACUBESMALL:
|
||||
case MAGMACUBESSMALL:
|
||||
case "slimesmall":
|
||||
case "magmacubesmall":
|
||||
((Slime) e).setSize(2);
|
||||
break;
|
||||
case SLIMEBIG:
|
||||
case SLIMESBIG:
|
||||
case MAGMACUBEBIG:
|
||||
case MAGMACUBESBIG:
|
||||
case "slimebig":
|
||||
case "magmacubebig":
|
||||
((Slime) e).setSize(3);
|
||||
break;
|
||||
case SLIMEHUGE:
|
||||
case SLIMESHUGE:
|
||||
case MAGMACUBEHUGE:
|
||||
case MAGMACUBESHUGE:
|
||||
case "slimehuge":
|
||||
case "magmacubehuge":
|
||||
((Slime) e).setSize(4);
|
||||
break;
|
||||
case SKELETON:
|
||||
case SKELETONS:
|
||||
((Skeleton) e).getEquipment().setItemInHand(new ItemStack(Material.BOW, 1));
|
||||
break;
|
||||
case ZOMBIEPIGMAN:
|
||||
case ZOMBIEPIGMEN:
|
||||
((PigZombie) e).getEquipment().setItemInHand(new ItemStack(Material.GOLD_SWORD, 1));
|
||||
break;
|
||||
case ZOMBIEVILLAGER:
|
||||
case ZOMBIEVILLAGERS:
|
||||
case "skeleton":
|
||||
e.getEquipment().setItemInHand(new ItemStack(Material.BOW, 1));
|
||||
break;
|
||||
case "zombiepigman":
|
||||
e.getEquipment().setItemInHand(new ItemStack(Material.GOLD_SWORD, 1));
|
||||
break;
|
||||
case "zombievillager":
|
||||
((Zombie) e).setVillager(true);
|
||||
break;
|
||||
case BABYZOMBIEVILLAGER:
|
||||
case BABYZOMBIEVILLAGERS:
|
||||
case "babyzombievillager":
|
||||
((Zombie) e).setVillager(true);
|
||||
case BABYZOMBIE:
|
||||
case BABYZOMBIES:
|
||||
case BABYPIGMAN:
|
||||
case BABYPIGMEN:
|
||||
case "babyzombie":
|
||||
case "babypigman":
|
||||
((Zombie) e).setBaby(true);
|
||||
break;
|
||||
case WITHERSKELETON:
|
||||
case WITHERSKELETONS:
|
||||
((Skeleton) e).getEquipment().setItemInHand(new ItemStack(Material.STONE_SWORD, 1));
|
||||
case "witherskeleton":
|
||||
e.getEquipment().setItemInHand(new ItemStack(Material.STONE_SWORD, 1));
|
||||
((Skeleton) e).setSkeletonType(SkeletonType.WITHER);
|
||||
break;
|
||||
case HORSE:
|
||||
case HORSES:
|
||||
case "horse":
|
||||
((Horse) e).setVariant(Horse.Variant.HORSE);
|
||||
break;
|
||||
case DONKEY:
|
||||
case DONKEYS:
|
||||
case "donkey":
|
||||
((Horse) e).setVariant(Horse.Variant.DONKEY);
|
||||
break;
|
||||
case MULE:
|
||||
case MULES:
|
||||
case "mule":
|
||||
((Horse) e).setVariant(Horse.Variant.MULE);
|
||||
break;
|
||||
case SKELETONHORSE:
|
||||
case SKELETONHORSES:
|
||||
case "skeletonhorse":
|
||||
((Horse) e).setVariant(Horse.Variant.SKELETON_HORSE);
|
||||
break;
|
||||
case UNDEADHORSE:
|
||||
case UNDEADHORSES:
|
||||
case "undeadhorse":
|
||||
((Horse) e).setVariant(Horse.Variant.UNDEAD_HORSE);
|
||||
break;
|
||||
default:
|
||||
|
@ -32,14 +32,14 @@ public class SpecialWave extends AbstractWave
|
||||
}
|
||||
|
||||
int amount;
|
||||
switch (entry.getValue()) {
|
||||
case POWEREDCREEPERS:
|
||||
case ZOMBIEPIGMEN:
|
||||
case ANGRYWOLVES: amount = playerCount * 2; break;
|
||||
case SLIMES: amount = playerCount * 4; break;
|
||||
case GIANTS:
|
||||
case GHASTS: amount = 2;
|
||||
default: amount = playerCount + 1; break;
|
||||
switch (entry.getValue().getName()) {
|
||||
case "poweredcreeper":
|
||||
case "zombiepigman":
|
||||
case "angrywolf": amount = playerCount * 2; break;
|
||||
case "slime": amount = playerCount * 4; break;
|
||||
case "giant":
|
||||
case "ghast": amount = 2; break;
|
||||
default: amount = playerCount + 1; break;
|
||||
}
|
||||
|
||||
amount = (int) Math.max(1D, amount * super.getAmountMultiplier());
|
||||
|
Loading…
Reference in New Issue
Block a user