Downhill from here
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
package me.youhavetrouble.entiddy;
|
||||
|
||||
|
||||
import me.youhavetrouble.entiddy.SpecialEntities.JebSheep;
|
||||
import me.youhavetrouble.entiddy.SpecialEntities.Johnny;
|
||||
import me.youhavetrouble.entiddy.SpecialEntities.KillerBunny;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public enum Entiddy {
|
||||
|
||||
KILLER_BUNNY(EntityType.RABBIT, new KillerBunny()),
|
||||
JEB_SHEEP(EntityType.SHEEP, new JebSheep()),
|
||||
JOHNNY(EntityType.VINDICATOR, new Johnny());
|
||||
|
||||
private final EntityType entityType;
|
||||
private final EntiddyInterface entiddy;
|
||||
|
||||
Entiddy(EntityType entityType, EntiddyInterface entiddy) {
|
||||
this.entityType = entityType;
|
||||
this.entiddy = entiddy;
|
||||
}
|
||||
|
||||
public EntityType getEntityType() {
|
||||
return entityType;
|
||||
}
|
||||
|
||||
public EntiddyInterface entiddy() {
|
||||
return entiddy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn entity upside down. Doesn't work on players.
|
||||
* WARNING This overwrites entities name tag!
|
||||
*/
|
||||
public static void upsideDown(@NotNull LivingEntity entity) {
|
||||
if (entity instanceof Player) return;
|
||||
entity.setCustomName("Grumm");
|
||||
}
|
||||
|
||||
public static boolean isSpecialEntity(@NotNull LivingEntity entity) {
|
||||
if (entity instanceof Player) return false;
|
||||
for (Entiddy enTiddy: Entiddy.values()) {
|
||||
if (enTiddy.entiddy().isInstance(entity)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package me.youhavetrouble.entiddy;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface EntiddyInterface {
|
||||
|
||||
/**
|
||||
* @param location Location to spawn the entity at
|
||||
* @param spawnReason SpawnReason to set
|
||||
* @return Spawned entity
|
||||
*/
|
||||
Entity spawn(@NotNull Location location, @NotNull CreatureSpawnEvent.SpawnReason spawnReason);
|
||||
|
||||
boolean isInstance(LivingEntity entity);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package me.youhavetrouble.entiddy.SpecialEntities;
|
||||
|
||||
import me.youhavetrouble.entiddy.EntiddyInterface;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Rabbit;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class JebSheep implements EntiddyInterface {
|
||||
|
||||
@Override
|
||||
public Entity spawn(@NotNull Location location, @NotNull CreatureSpawnEvent.SpawnReason spawnReason) {
|
||||
if (location.getWorld() == null) {
|
||||
throw new NullPointerException("World cannot be null");
|
||||
}
|
||||
return location.getWorld().spawnEntity(location, EntityType.SHEEP, spawnReason, (entity) -> entity.setCustomName("jeb_"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInstance(LivingEntity entity) {
|
||||
if (!(entity instanceof Rabbit)) return false;
|
||||
return entity.getCustomName() != null && entity.getCustomName().equals("jeb_");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package me.youhavetrouble.entiddy.SpecialEntities;
|
||||
|
||||
import me.youhavetrouble.entiddy.EntiddyInterface;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Vindicator;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class Johnny implements EntiddyInterface {
|
||||
@Override
|
||||
public Entity spawn(@NotNull Location location, @NotNull CreatureSpawnEvent.SpawnReason spawnReason) {
|
||||
if (location.getWorld() == null) {
|
||||
throw new NullPointerException("World cannot be null");
|
||||
}
|
||||
return location.getWorld().spawnEntity(location, EntityType.VINDICATOR, spawnReason, (entity) -> {
|
||||
Vindicator johnny = (Vindicator) entity;
|
||||
johnny.setJohnny(true);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInstance(LivingEntity entity) {
|
||||
if (!(entity instanceof Vindicator)) return false;
|
||||
return ((Vindicator) entity).isJohnny();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package me.youhavetrouble.entiddy.SpecialEntities;
|
||||
|
||||
import me.youhavetrouble.entiddy.EntiddyInterface;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Rabbit;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class KillerBunny implements EntiddyInterface {
|
||||
|
||||
@Override
|
||||
public Entity spawn(@NotNull Location location, @NotNull CreatureSpawnEvent.SpawnReason spawnReason) {
|
||||
if (location.getWorld() == null) {
|
||||
throw new NullPointerException("World cannot be null");
|
||||
}
|
||||
return location.getWorld().spawnEntity(location, EntityType.RABBIT, spawnReason, (entity) -> {
|
||||
Rabbit rabbit = (Rabbit) entity;
|
||||
rabbit.setRabbitType(Rabbit.Type.THE_KILLER_BUNNY);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInstance(LivingEntity entity) {
|
||||
if (!(entity instanceof Rabbit)) return false;
|
||||
return ((Rabbit) entity).getRabbitType().equals(Rabbit.Type.THE_KILLER_BUNNY);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package me.youhavetrouble.entiddy.SpecialEntities;
|
||||
|
||||
import me.youhavetrouble.entiddy.EntiddyInterface;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Rabbit;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class Toast implements EntiddyInterface {
|
||||
|
||||
@Override
|
||||
public Entity spawn(@NotNull Location location, CreatureSpawnEvent.@NotNull SpawnReason spawnReason) {
|
||||
if (location.getWorld() == null) {
|
||||
throw new NullPointerException("World cannot be null");
|
||||
}
|
||||
return location.getWorld().spawnEntity(location, EntityType.RABBIT, spawnReason, (entity) -> entity.setCustomName("Toast"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInstance(LivingEntity entity) {
|
||||
if (!(entity instanceof Rabbit)) return false;
|
||||
return entity.getCustomName() != null && entity.getCustomName().equals("Toast");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user