Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2e0b137666 | |||
| 956abd5ef0 | |||
| b89e332ed4 |
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>me.youhavetrouble</groupId>
|
<groupId>me.youhavetrouble</groupId>
|
||||||
<artifactId>Entiddy</artifactId>
|
<artifactId>Entiddy</artifactId>
|
||||||
<version>1.1.0</version>
|
<version>2.0.0-pre</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>Entiddy</name>
|
<name>Entiddy</name>
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import me.youhavetrouble.entiddy.SpecialEntities.JebSheep;
|
|||||||
import me.youhavetrouble.entiddy.SpecialEntities.Johnny;
|
import me.youhavetrouble.entiddy.SpecialEntities.Johnny;
|
||||||
import me.youhavetrouble.entiddy.SpecialEntities.KillerBunny;
|
import me.youhavetrouble.entiddy.SpecialEntities.KillerBunny;
|
||||||
import me.youhavetrouble.entiddy.SpecialEntities.Toast;
|
import me.youhavetrouble.entiddy.SpecialEntities.Toast;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.entity.EntityType;
|
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;
|
||||||
@@ -12,9 +13,27 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
|
|
||||||
public enum Entiddy {
|
public enum Entiddy {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Killer bunny that attacks players monthy python style
|
||||||
|
*/
|
||||||
KILLER_BUNNY(EntityType.RABBIT, new KillerBunny()),
|
KILLER_BUNNY(EntityType.RABBIT, new KillerBunny()),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Its wool cycles with interpolation through all dye colors
|
||||||
|
* Sheep with rgb lighting
|
||||||
|
*/
|
||||||
JEB_SHEEP(EntityType.SHEEP, new JebSheep()),
|
JEB_SHEEP(EntityType.SHEEP, new JebSheep()),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Johnny is hostile to basically every mob with few exceptions
|
||||||
|
* HERE'S JOHNNY
|
||||||
|
*/
|
||||||
JOHNNY(EntityType.VINDICATOR, new Johnny()),
|
JOHNNY(EntityType.VINDICATOR, new Johnny()),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Toast has the appearance of a black dutch, with a large black and white patch and more black fur around the face
|
||||||
|
* than the natural black and white spotted rabbit.
|
||||||
|
*/
|
||||||
TOAST(EntityType.RABBIT, new Toast());
|
TOAST(EntityType.RABBIT, new Toast());
|
||||||
|
|
||||||
private final EntityType entityType;
|
private final EntityType entityType;
|
||||||
@@ -39,7 +58,7 @@ public enum Entiddy {
|
|||||||
*/
|
*/
|
||||||
public static void upsideDown(@NotNull LivingEntity entity) {
|
public static void upsideDown(@NotNull LivingEntity entity) {
|
||||||
if (entity instanceof Player) return;
|
if (entity instanceof Player) return;
|
||||||
entity.setCustomName("Grumm");
|
entity.customName(Component.text("Grumm"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -47,10 +66,21 @@ public enum Entiddy {
|
|||||||
*/
|
*/
|
||||||
public static boolean isSpecialEntity(@NotNull LivingEntity entity) {
|
public static boolean isSpecialEntity(@NotNull LivingEntity entity) {
|
||||||
if (entity instanceof Player) return false;
|
if (entity instanceof Player) return false;
|
||||||
for (Entiddy enTiddy: Entiddy.values()) {
|
for (Entiddy entiddy: Entiddy.values()) {
|
||||||
if (enTiddy.entiddy().isInstance(entity)) return true;
|
if (entiddy.entiddy().isInstance(entity)) return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Special entity type or null
|
||||||
|
*/
|
||||||
|
public static Entiddy fromEntity(@NotNull LivingEntity entity) {
|
||||||
|
if (entity instanceof Player) return null;
|
||||||
|
for (Entiddy entiddy: Entiddy.values()) {
|
||||||
|
if (entiddy.entiddy().isInstance(entity)) return entiddy;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
package me.youhavetrouble.entiddy.SpecialEntities;
|
package me.youhavetrouble.entiddy.SpecialEntities;
|
||||||
|
|
||||||
import me.youhavetrouble.entiddy.EntiddyInterface;
|
import me.youhavetrouble.entiddy.EntiddyInterface;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.*;
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.bukkit.entity.LivingEntity;
|
|
||||||
import org.bukkit.entity.Rabbit;
|
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class JebSheep implements EntiddyInterface {
|
public class JebSheep implements EntiddyInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -16,12 +16,15 @@ public class JebSheep implements EntiddyInterface {
|
|||||||
if (location.getWorld() == null) {
|
if (location.getWorld() == null) {
|
||||||
throw new NullPointerException("World cannot be null");
|
throw new NullPointerException("World cannot be null");
|
||||||
}
|
}
|
||||||
return location.getWorld().spawnEntity(location, EntityType.SHEEP, spawnReason, (entity) -> entity.setCustomName("jeb_"));
|
return location.getWorld().spawnEntity(location, EntityType.SHEEP, spawnReason, (entity) -> {
|
||||||
|
entity.customName(Component.text("jeb_"));
|
||||||
|
entity.setCustomNameVisible(false);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isInstance(@NotNull LivingEntity entity) {
|
public boolean isInstance(@NotNull LivingEntity entity) {
|
||||||
if (!(entity instanceof Rabbit)) return false;
|
if (!(entity instanceof Sheep)) return false;
|
||||||
return entity.getCustomName() != null && entity.getCustomName().equals("jeb_");
|
return Objects.equals(entity.customName(), Component.text("jeb_"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package me.youhavetrouble.entiddy.SpecialEntities;
|
package me.youhavetrouble.entiddy.SpecialEntities;
|
||||||
|
|
||||||
import me.youhavetrouble.entiddy.EntiddyInterface;
|
import me.youhavetrouble.entiddy.EntiddyInterface;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
@@ -9,6 +10,8 @@ import org.bukkit.entity.Rabbit;
|
|||||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class Toast implements EntiddyInterface {
|
public class Toast implements EntiddyInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -16,12 +19,16 @@ public class Toast implements EntiddyInterface {
|
|||||||
if (location.getWorld() == null) {
|
if (location.getWorld() == null) {
|
||||||
throw new NullPointerException("World cannot be null");
|
throw new NullPointerException("World cannot be null");
|
||||||
}
|
}
|
||||||
return location.getWorld().spawnEntity(location, EntityType.RABBIT, spawnReason, (entity) -> entity.setCustomName("Toast"));
|
return location.getWorld().spawnEntity(location, EntityType.RABBIT, spawnReason,
|
||||||
|
(entity) -> {
|
||||||
|
entity.customName(Component.text("Toast"));
|
||||||
|
entity.setCustomNameVisible(false);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isInstance(@NotNull LivingEntity entity) {
|
public boolean isInstance(@NotNull LivingEntity entity) {
|
||||||
if (!(entity instanceof Rabbit)) return false;
|
if (!(entity instanceof Rabbit)) return false;
|
||||||
return entity.getCustomName() != null && entity.getCustomName().equals("Toast");
|
return Objects.equals(entity.customName(), Component.text("Toast"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user