faster checks
This commit is contained in:
@@ -16,13 +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.customName(Component.text("jeb_")));
|
||||
return location.getWorld().spawnEntity(location, EntityType.SHEEP, spawnReason, (entity) -> {
|
||||
entity.customName(Component.text("jeb_"));
|
||||
entity.setCustomNameVisible(false);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInstance(@NotNull LivingEntity entity) {
|
||||
if (!(entity instanceof Sheep)) return false;
|
||||
return entity.customName() != null && Objects.equals(entity.customName(), Component.text("jeb_"));
|
||||
return Objects.equals(entity.customName(), Component.text("jeb_"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,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
|
||||
@@ -18,12 +20,15 @@ public class Toast implements EntiddyInterface {
|
||||
throw new NullPointerException("World cannot be null");
|
||||
}
|
||||
return location.getWorld().spawnEntity(location, EntityType.RABBIT, spawnReason,
|
||||
(entity) -> entity.customName(Component.text("Toast")));
|
||||
(entity) -> {
|
||||
entity.customName(Component.text("Toast"));
|
||||
entity.setCustomNameVisible(false);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
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