Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f2bae4adee | |||
| 75457eca4b | |||
| 2e0b137666 | |||
| 956abd5ef0 | |||
| b89e332ed4 | |||
| 301a358a60 | |||
| f5c33a9476 | |||
| 9403e87a32 | |||
| 98a7774230 | |||
| 7452dca5e3 | |||
| 48b44c7173 | |||
| ae307863b4 |
@@ -6,14 +6,14 @@
|
||||
|
||||
<groupId>me.youhavetrouble</groupId>
|
||||
<artifactId>Entiddy</artifactId>
|
||||
<version>1.0</version>
|
||||
<version>2.0.0</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>EnTiddy</name>
|
||||
<name>Entiddy</name>
|
||||
|
||||
<description>A very serious library concerning entities</description>
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<java.version>17</java.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
Guys, I swear this is a serious library.
|
||||
|
||||
## Dependency
|
||||
|
||||
Current version: [](https://jitpack.io/#YouHaveTrouble/Entiddy)
|
||||
|
||||
### Maven
|
||||
|
||||
```xml
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
```
|
||||
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>com.github.YouHaveTrouble</groupId>
|
||||
<artifactId>Entiddy</artifactId>
|
||||
<version>VERSION</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
### Gradle
|
||||
|
||||
```
|
||||
allprojects {
|
||||
repositories {
|
||||
...
|
||||
maven { url 'https://jitpack.io' }
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
```
|
||||
dependencies {
|
||||
implementation 'com.github.YouHaveTrouble:Entiddy:VERSION'
|
||||
}
|
||||
```
|
||||
@@ -4,6 +4,8 @@ package me.youhavetrouble.entiddy;
|
||||
import me.youhavetrouble.entiddy.SpecialEntities.JebSheep;
|
||||
import me.youhavetrouble.entiddy.SpecialEntities.Johnny;
|
||||
import me.youhavetrouble.entiddy.SpecialEntities.KillerBunny;
|
||||
import me.youhavetrouble.entiddy.SpecialEntities.Toast;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -11,9 +13,28 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public enum Entiddy {
|
||||
|
||||
/**
|
||||
* Killer bunny that attacks players monthy python style
|
||||
*/
|
||||
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()),
|
||||
JOHNNY(EntityType.VINDICATOR, new Johnny());
|
||||
|
||||
/**
|
||||
* Johnny is hostile to basically every mob with few exceptions
|
||||
* HERE'S 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());
|
||||
|
||||
private final EntityType entityType;
|
||||
private final EntiddyInterface entiddy;
|
||||
@@ -37,15 +58,29 @@ public enum Entiddy {
|
||||
*/
|
||||
public static void upsideDown(@NotNull LivingEntity entity) {
|
||||
if (entity instanceof Player) return;
|
||||
entity.setCustomName("Grumm");
|
||||
entity.customName(Component.text("Grumm"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return True if entity is one of special/easter egg entities
|
||||
*/
|
||||
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;
|
||||
for (Entiddy entiddy: Entiddy.values()) {
|
||||
if (entiddy.entiddy().isInstance(entity)) return true;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,6 +15,9 @@ public interface EntiddyInterface {
|
||||
*/
|
||||
Entity spawn(@NotNull Location location, @NotNull CreatureSpawnEvent.SpawnReason spawnReason);
|
||||
|
||||
boolean isInstance(LivingEntity entity);
|
||||
/**
|
||||
* @return True if the entity is an instance of the specific special/easter egg type
|
||||
*/
|
||||
boolean isInstance(@NotNull LivingEntity entity);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package me.youhavetrouble.entiddy.SpecialEntities;
|
||||
|
||||
import me.youhavetrouble.entiddy.EntiddyInterface;
|
||||
import net.kyori.adventure.text.Component;
|
||||
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.entity.*;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class JebSheep implements EntiddyInterface {
|
||||
|
||||
@Override
|
||||
@@ -16,12 +16,15 @@ public class JebSheep implements EntiddyInterface {
|
||||
if (location.getWorld() == 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
|
||||
public boolean isInstance(LivingEntity entity) {
|
||||
if (!(entity instanceof Rabbit)) return false;
|
||||
return entity.getCustomName() != null && entity.getCustomName().equals("jeb_");
|
||||
public boolean isInstance(@NotNull LivingEntity entity) {
|
||||
if (!(entity instanceof Sheep)) return false;
|
||||
return Objects.equals(entity.customName(), Component.text("jeb_"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ public class Johnny implements EntiddyInterface {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInstance(LivingEntity entity) {
|
||||
public boolean isInstance(@NotNull LivingEntity entity) {
|
||||
if (!(entity instanceof Vindicator)) return false;
|
||||
return ((Vindicator) entity).isJohnny();
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public class KillerBunny implements EntiddyInterface {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInstance(LivingEntity entity) {
|
||||
public boolean isInstance(@NotNull LivingEntity entity) {
|
||||
if (!(entity instanceof Rabbit)) return false;
|
||||
return ((Rabbit) entity).getRabbitType().equals(Rabbit.Type.THE_KILLER_BUNNY);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package me.youhavetrouble.entiddy.SpecialEntities;
|
||||
|
||||
import me.youhavetrouble.entiddy.EntiddyInterface;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
@@ -9,6 +10,8 @@ import org.bukkit.entity.Rabbit;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class Toast implements EntiddyInterface {
|
||||
|
||||
@Override
|
||||
@@ -16,12 +19,16 @@ public class Toast implements EntiddyInterface {
|
||||
if (location.getWorld() == 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
|
||||
public boolean isInstance(LivingEntity entity) {
|
||||
public boolean isInstance(@NotNull LivingEntity entity) {
|
||||
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