use of org.bukkit.entity.Sittable in project Prism-Bukkit by prism.
the class EntitySerializer method serialize.
/**
* Serialize entity.
* @param entity Entity.
*/
public final void serialize(Entity entity) {
entityName = entity.getType().name().toLowerCase();
// Get custom name
customName = entity.getCustomName();
// Get animal age
if (entity instanceof Ageable) {
isAdult = ((Ageable) entity).isAdult();
}
// Owner
if (entity instanceof Tameable) {
final Tameable mob = (Tameable) entity;
if (mob.getOwner() != null) {
tamingOwner = mob.getOwner().getUniqueId().toString();
} else if (mob.isTamed()) {
tamingOwner = "-none-";
}
}
// Sitting
if (entity instanceof Sittable) {
sitting = ((Sittable) entity).isSitting();
}
EntityDamageEvent damageEvent = entity.getLastDamageCause();
// Saves us the null check
if (damageEvent instanceof EntityDamageByEntityEvent && !damageEvent.isCancelled() && damageEvent.getDamage() > ((LivingEntity) entity).getHealth()) {
EntityDamageByEntityEvent e = (EntityDamageByEntityEvent) damageEvent;
if (e.getDamager() instanceof Projectile) {
customDesc = EntityUtils.getCustomProjectileDescription((Projectile) e.getDamager());
}
}
serializer(entity);
}
Aggregations