3.0.0-SNAPSHOT-U16

Added Endermite, Guardian, Llama, Parrot, PolarBear, Rabbit and Shulker entity handlers.
Added Endermite, Guardian, Shulker, Pig, Sheep, Cow, Chicken, Squid, Wolf, MushroomCow, Snowman, Ocelot, IronGolem, Horse, Rabbit, PolarBear, Llama, Parrot, Villager to EntityFinder.
This commit is contained in:
AMinecraftDev 2018-07-01 22:26:51 +08:00
parent 2cc9625c0a
commit 25b058deb3
11 changed files with 236 additions and 4 deletions

View File

@ -13,8 +13,6 @@ import java.util.List;
* @author Charles Cullen
* @version 1.0.0
* @since 28-Jun-18
*
* TODO: Finish all the possible boss options.
*/
public enum EntityFinder {
@ -49,7 +47,26 @@ public enum EntityFinder {
ENDER_DRAGON("EnderDragon", EntityType.ENDER_DRAGON, "enderdragon", "ender_dragon", "ender dragon"),
WITHER("Wither", EntityType.WITHER, "wither"),
BAT("Bat", EntityType.BAT, "bat"),
WITCH("Witch", EntityType.WITCH, "witch");
WITCH("Witch", EntityType.WITCH, "witch"),
ENDERMITE("Endermite", new EndermiteHandler(), "endermite"),
GUARDIAN("Guardian", new GuardianHandler(), "guardian"),
SHULKER("Shulker", new ShulkerHandler(), "shulker"),
PIG("Pig", EntityType.PIG, "pig"),
SHEEP("Sheep", EntityType.SHEEP, "sheep"),
COW("Cow", EntityType.COW, "cow"),
CHICKEN("Chicken", EntityType.CHICKEN, "chicken"),
SQUID("Squid", EntityType.SQUID, "squid"),
WOLF("Wolf", EntityType.WOLF, "wolf"),
MUSHROOM_COW("MushroomCow", EntityType.MUSHROOM_COW, "mushroomcow", "mushroom_cow", "mushroom cow", "mooshroom"),
SNOWMAN("Snowman", EntityType.SNOWMAN, "snowman"),
OCELOT("Ocelot", EntityType.OCELOT, "ocelot"),
IRON_GOLEM("IronGolem", EntityType.IRON_GOLEM, "irongolem", "iron_golem", "iron golem", "ig"),
HORSE("Horse", EntityType.HORSE, "horse"),
RABBIT("Rabbit", new RabbitHandler(), "rabbit"),
POLAR_BEAR("PolarBear", new PolarBearHandler(), "polarbear", "polar_bear", "polar bear", "snowbear", "snow_bear", "snow bear"),
LLAMA("Llama", new LlamaHandler(), "llama"),
PARROT("Parrot", new ParrotHandler(), "parrot"),
VILLAGER("Villager", new VillagerHandler(), "villager");
@Getter private ICustomEntityHandler customEntityHandler;
@Getter private List<String> names = new ArrayList<>();
@ -76,4 +93,14 @@ public enum EntityFinder {
this.customEntityHandler = null;
}
public static EntityFinder get(String name) {
for(EntityFinder entityFinder : values()) {
for (String s : entityFinder.getNames()) {
if(name.equalsIgnoreCase(s)) return entityFinder;
}
}
return null;
}
}

View File

@ -19,6 +19,10 @@ public class DonkeyHorseHandler implements ICustomEntityHandler {
@Override
public LivingEntity getBaseEntity(String entityType, Location spawnLocation) {
if(this.versionHandler.getVersion().isLessThan(Versions.v1_11_R1)) {
throw new NullPointerException("This feature is only implemented in version 1.11 and above of Minecraft.");
}
if(this.versionHandler.getVersion().isHigherThanOrEqualTo(Versions.v1_11_R1)) {
return (LivingEntity) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.DONKEY);
}

View File

@ -0,0 +1,27 @@
package net.aminecraftdev.custombosses.utils.entity.handlers;
import net.aminecraftdev.custombosses.utils.Versions;
import net.aminecraftdev.custombosses.utils.entity.ICustomEntityHandler;
import net.aminecraftdev.custombosses.utils.version.VersionHandler;
import org.bukkit.Location;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 01-Jul-18
*/
public class EndermiteHandler implements ICustomEntityHandler {
private VersionHandler versionHandler = new VersionHandler();
@Override
public LivingEntity getBaseEntity(String entityType, Location spawnLocation) {
if(this.versionHandler.getVersion().isLessThan(Versions.v1_8_R1)) {
throw new NullPointerException("This feature is only implemented in version 1.8 and above of Minecraft.");
}
return (LivingEntity) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.ENDERMITE);
}
}

View File

@ -0,0 +1,27 @@
package net.aminecraftdev.custombosses.utils.entity.handlers;
import net.aminecraftdev.custombosses.utils.Versions;
import net.aminecraftdev.custombosses.utils.entity.ICustomEntityHandler;
import net.aminecraftdev.custombosses.utils.version.VersionHandler;
import org.bukkit.Location;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 01-Jul-18
*/
public class GuardianHandler implements ICustomEntityHandler {
private VersionHandler versionHandler = new VersionHandler();
@Override
public LivingEntity getBaseEntity(String entityType, Location spawnLocation) {
if(this.versionHandler.getVersion().isLessThan(Versions.v1_8_R1)) {
throw new NullPointerException("This feature is only implemented in version 1.8 and above of Minecraft.");
}
return (LivingEntity) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.GUARDIAN);
}
}

View File

@ -0,0 +1,35 @@
package net.aminecraftdev.custombosses.utils.entity.handlers;
import net.aminecraftdev.custombosses.utils.Versions;
import net.aminecraftdev.custombosses.utils.entity.ICustomEntityHandler;
import net.aminecraftdev.custombosses.utils.version.VersionHandler;
import org.bukkit.Location;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Horse;
import org.bukkit.entity.LivingEntity;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 01-Jul-18
*/
public class LlamaHandler implements ICustomEntityHandler {
private VersionHandler versionHandler = new VersionHandler();
@Override
public LivingEntity getBaseEntity(String entityType, Location spawnLocation) {
if(this.versionHandler.getVersion().isLessThan(Versions.v1_11_R1)) {
throw new NullPointerException("This feature is only implemented in version 1.11 and above of Minecraft.");
}
if(this.versionHandler.getVersion().isHigherThanOrEqualTo(Versions.v1_11_R1)) {
return (LivingEntity) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.LLAMA);
}
Horse horse = (Horse) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.HORSE);
horse.setVariant(Horse.Variant.LLAMA);
return horse;
}
}

View File

@ -19,6 +19,10 @@ public class MuleHorseHandler implements ICustomEntityHandler {
@Override
public LivingEntity getBaseEntity(String entityType, Location spawnLocation) {
if(this.versionHandler.getVersion().isLessThan(Versions.v1_11_R1)) {
throw new NullPointerException("This feature is only implemented in version 1.11 and above of Minecraft.");
}
if(this.versionHandler.getVersion().isHigherThanOrEqualTo(Versions.v1_11_R1)) {
return (LivingEntity) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.MULE);
}

View File

@ -0,0 +1,27 @@
package net.aminecraftdev.custombosses.utils.entity.handlers;
import net.aminecraftdev.custombosses.utils.Versions;
import net.aminecraftdev.custombosses.utils.entity.ICustomEntityHandler;
import net.aminecraftdev.custombosses.utils.version.VersionHandler;
import org.bukkit.Location;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 01-Jul-18
*/
public class ParrotHandler implements ICustomEntityHandler {
private VersionHandler versionHandler = new VersionHandler();
@Override
public LivingEntity getBaseEntity(String entityType, Location spawnLocation) {
if(this.versionHandler.getVersion().isLessThan(Versions.v1_12_R1)) {
throw new NullPointerException("This feature is only implemented in version 1.12 and above of Minecraft.");
}
return (LivingEntity) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.PARROT);
}
}

View File

@ -0,0 +1,27 @@
package net.aminecraftdev.custombosses.utils.entity.handlers;
import net.aminecraftdev.custombosses.utils.Versions;
import net.aminecraftdev.custombosses.utils.entity.ICustomEntityHandler;
import net.aminecraftdev.custombosses.utils.version.VersionHandler;
import org.bukkit.Location;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 01-Jul-18
*/
public class PolarBearHandler implements ICustomEntityHandler {
private VersionHandler versionHandler = new VersionHandler();
@Override
public LivingEntity getBaseEntity(String entityType, Location spawnLocation) {
if(this.versionHandler.getVersion().isLessThan(Versions.v1_10_R1)) {
throw new NullPointerException("This feature is only implemented in version 1.10 and above of Minecraft.");
}
return (LivingEntity) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.POLAR_BEAR);
}
}

View File

@ -0,0 +1,27 @@
package net.aminecraftdev.custombosses.utils.entity.handlers;
import net.aminecraftdev.custombosses.utils.Versions;
import net.aminecraftdev.custombosses.utils.entity.ICustomEntityHandler;
import net.aminecraftdev.custombosses.utils.version.VersionHandler;
import org.bukkit.Location;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 01-Jul-18
*/
public class RabbitHandler implements ICustomEntityHandler {
private VersionHandler versionHandler = new VersionHandler();
@Override
public LivingEntity getBaseEntity(String entityType, Location spawnLocation) {
if(this.versionHandler.getVersion().isLessThan(Versions.v1_8_R1)) {
throw new NullPointerException("This feature is only implemented in version 1.8 and above of Minecraft.");
}
return (LivingEntity) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.RABBIT);
}
}

View File

@ -0,0 +1,27 @@
package net.aminecraftdev.custombosses.utils.entity.handlers;
import net.aminecraftdev.custombosses.utils.Versions;
import net.aminecraftdev.custombosses.utils.entity.ICustomEntityHandler;
import net.aminecraftdev.custombosses.utils.version.VersionHandler;
import org.bukkit.Location;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 01-Jul-18
*/
public class ShulkerHandler implements ICustomEntityHandler {
private VersionHandler versionHandler = new VersionHandler();
@Override
public LivingEntity getBaseEntity(String entityType, Location spawnLocation) {
if(this.versionHandler.getVersion().isLessThan(Versions.v1_9_R1)) {
throw new NullPointerException("This feature is only implemented in version 1.9 and above of Minecraft.");
}
return (LivingEntity) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.SHULKER);
}
}

View File

@ -19,7 +19,7 @@
</modules>
<properties>
<plugin.version>3.0.0-SNAPSHOT-U15</plugin.version>
<plugin.version>3.0.0-SNAPSHOT-U16</plugin.version>
<plugin.name>CustomBosses</plugin.name>
<plugin.main>net.aminecraftdev.custombosses.CustomBosses</plugin.main>
<plugin.author>AMinecraftDev</plugin.author>