Added support for 1.13 entities

This commit is contained in:
Esophose 2019-08-22 10:32:14 -06:00
parent e9d0dbeb62
commit 8aa867c615
7 changed files with 148 additions and 1 deletions

View File

@ -69,6 +69,11 @@ public enum EntityFinder {
LLAMA("Llama", new LlamaHandler(), "llama"),
PARROT("Parrot", new ParrotHandler(), "parrot"),
VILLAGER("Villager", new VillagerHandler(), "villager"),
DOLPHIN("Dolphin", new DolphinHandler(), "dolphin"),
DROWNED("Drowned", new DrownedHandler(), "drowned"),
FISH("Fish", new FishHandler(), "fish", "tropicalfish", "tropical fish", "tropical_fish", "clownfish", "cod", "salmon", "pufferfish"),
TURTLE("Turtle", new TurtleHandler(), "turtle"),
PHANTOM("Phantom", new PhantomHandler(), "phantom"),
CAT("Cat", new CatHandler(), "cat"),
FOX("Fox", new FoxHandler(), "fox"),
PANDA("Panda", new PandaHandler(), "panda"),

View File

@ -0,0 +1,22 @@
package com.songoda.epicbosses.utils.entity.handlers;
import com.songoda.epicbosses.utils.Versions;
import com.songoda.epicbosses.utils.entity.ICustomEntityHandler;
import com.songoda.epicbosses.utils.version.VersionHandler;
import org.bukkit.Location;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
public class DolphinHandler implements ICustomEntityHandler {
private VersionHandler versionHandler = new VersionHandler();
@Override
public LivingEntity getBaseEntity(String entityType, Location spawnLocation) {
if(this.versionHandler.getVersion().isLessThan(Versions.v1_13_R1)) {
throw new NullPointerException("This feature is only implemented in version 1.13 and above of Minecraft.");
}
return (LivingEntity) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.DOLPHIN);
}
}

View File

@ -0,0 +1,22 @@
package com.songoda.epicbosses.utils.entity.handlers;
import com.songoda.epicbosses.utils.Versions;
import com.songoda.epicbosses.utils.entity.ICustomEntityHandler;
import com.songoda.epicbosses.utils.version.VersionHandler;
import org.bukkit.Location;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
public class DrownedHandler implements ICustomEntityHandler {
private VersionHandler versionHandler = new VersionHandler();
@Override
public LivingEntity getBaseEntity(String entityType, Location spawnLocation) {
if(this.versionHandler.getVersion().isLessThan(Versions.v1_13_R1)) {
throw new NullPointerException("This feature is only implemented in version 1.13 and above of Minecraft.");
}
return (LivingEntity) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.DROWNED);
}
}

View File

@ -0,0 +1,44 @@
package com.songoda.epicbosses.utils.entity.handlers;
import com.songoda.epicbosses.utils.Versions;
import com.songoda.epicbosses.utils.entity.ICustomEntityHandler;
import com.songoda.epicbosses.utils.version.VersionHandler;
import org.bukkit.Location;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Fish;
import org.bukkit.entity.LivingEntity;
public class FishHandler implements ICustomEntityHandler {
private VersionHandler versionHandler = new VersionHandler();
@Override
public LivingEntity getBaseEntity(String entityType, Location spawnLocation) {
if(this.versionHandler.getVersion().isLessThan(Versions.v1_13_R1)) {
throw new NullPointerException("This feature is only implemented in version 1.13 and above of Minecraft.");
}
EntityType fishEntityType;
String type = entityType.toUpperCase().replace("_", "");
switch (type) {
case "COD":
fishEntityType = EntityType.COD;
break;
case "PUFFERFISH":
fishEntityType = EntityType.PUFFERFISH;
break;
case "SALMON":
fishEntityType = EntityType.SALMON;
break;
case "FISH":
case "TROPICALFISH":
case "CLOWNFISH":
default:
fishEntityType = EntityType.TROPICAL_FISH;
break;
}
return (LivingEntity) spawnLocation.getWorld().spawnEntity(spawnLocation, fishEntityType);
}
}

View File

@ -19,7 +19,7 @@ public class MagmaCubeHandler implements ICustomEntityHandler {
int size = 4;
if (entityType.contains(":")) {
String[] split = entityType.split(":");
size = Integer.valueOf(split[1]);
size = Integer.parseInt(split[1]);
}
MagmaCube magmaCube = (MagmaCube) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.MAGMA_CUBE);

View File

@ -0,0 +1,32 @@
package com.songoda.epicbosses.utils.entity.handlers;
import com.songoda.epicbosses.utils.Versions;
import com.songoda.epicbosses.utils.entity.ICustomEntityHandler;
import com.songoda.epicbosses.utils.version.VersionHandler;
import org.bukkit.Location;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Phantom;
public class PhantomHandler implements ICustomEntityHandler {
private VersionHandler versionHandler = new VersionHandler();
@Override
public LivingEntity getBaseEntity(String entityType, Location spawnLocation) {
if(this.versionHandler.getVersion().isLessThan(Versions.v1_13_R1)) {
throw new NullPointerException("This feature is only implemented in version 1.13 and above of Minecraft.");
}
int size = 4;
if (entityType.contains(":")) {
String[] split = entityType.split(":");
size = Integer.parseInt(split[1]);
}
Phantom phantom = (Phantom) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.PHANTOM);
phantom.setSize(size);
return phantom;
}
}

View File

@ -0,0 +1,22 @@
package com.songoda.epicbosses.utils.entity.handlers;
import com.songoda.epicbosses.utils.Versions;
import com.songoda.epicbosses.utils.entity.ICustomEntityHandler;
import com.songoda.epicbosses.utils.version.VersionHandler;
import org.bukkit.Location;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
public class TurtleHandler implements ICustomEntityHandler {
private VersionHandler versionHandler = new VersionHandler();
@Override
public LivingEntity getBaseEntity(String entityType, Location spawnLocation) {
if(this.versionHandler.getVersion().isLessThan(Versions.v1_13_R1)) {
throw new NullPointerException("This feature is only implemented in version 1.13 and above of Minecraft.");
}
return (LivingEntity) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.TURTLE);
}
}