Minor refactoring in EntityDeathListener

This commit is contained in:
Intelli 2022-03-01 20:17:12 -07:00
parent 7c7fd200d2
commit a6869176be
2 changed files with 458 additions and 395 deletions

View File

@ -5,9 +5,11 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.attribute.Attributable;
import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeInstance;
@ -59,6 +61,7 @@ import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import org.bukkit.projectiles.ProjectileSource;
import net.coreprotect.CoreProtect;
import net.coreprotect.bukkit.BukkitAdapter;
import net.coreprotect.config.Config;
import net.coreprotect.consumer.Queue;
@ -66,6 +69,444 @@ import net.coreprotect.utility.serialize.ItemMetaHandler;
public final class EntityDeathListener extends Queue implements Listener {
public static void parseEntityKills(String message) {
message = message.trim().toLowerCase(Locale.ROOT);
if (!message.contains(" ")) {
return;
}
String[] args = message.split(" ");
if (args.length < 2 || !args[0].replaceFirst("/", "").equals("kill") || !args[1].startsWith("@e")) {
return;
}
List<LivingEntity> entityList = new ArrayList<>();
for (World world : Bukkit.getWorlds()) {
List<LivingEntity> livingEntities = world.getLivingEntities();
for (LivingEntity entity : livingEntities) {
if (entity instanceof Player) {
continue;
}
if (entity.isValid()) {
entityList.add(entity);
}
}
}
Bukkit.getScheduler().runTask(CoreProtect.getInstance(), () -> {
for (LivingEntity entity : entityList) {
if (entity != null && entity.isDead()) {
logEntityDeath(entity, "#command");
}
}
});
}
protected static void logEntityDeath(LivingEntity entity, String e) {
if (!Config.getConfig(entity.getWorld()).ENTITY_KILLS) {
return;
}
EntityDamageEvent damage = entity.getLastDamageCause();
if (damage == null) {
return;
}
if (e == null) {
e = "";
}
boolean skip = true;
if (!Config.getConfig(entity.getWorld()).SKIP_GENERIC_DATA || (!(entity instanceof Zombie) && !(entity instanceof Skeleton))) {
skip = false;
}
if (damage instanceof EntityDamageByEntityEvent) {
EntityDamageByEntityEvent attack = (EntityDamageByEntityEvent) damage;
Entity attacker = attack.getDamager();
if (attacker instanceof Player) {
Player player = (Player) attacker;
e = player.getName();
}
else if (attacker instanceof AbstractArrow) {
AbstractArrow arrow = (AbstractArrow) attacker;
ProjectileSource shooter = arrow.getShooter();
if (shooter instanceof Player) {
Player player = (Player) shooter;
e = player.getName();
}
else if (shooter instanceof LivingEntity) {
EntityType entityType = ((LivingEntity) shooter).getType();
if (entityType != null) { // Check for MyPet plugin
String name = entityType.name().toLowerCase(Locale.ROOT);
e = "#" + name;
}
}
}
else if (attacker instanceof ThrownPotion) {
ThrownPotion potion = (ThrownPotion) attacker;
ProjectileSource shooter = potion.getShooter();
if (shooter instanceof Player) {
Player player = (Player) shooter;
e = player.getName();
}
else if (shooter instanceof LivingEntity) {
EntityType entityType = ((LivingEntity) shooter).getType();
if (entityType != null) { // Check for MyPet plugin
String name = entityType.name().toLowerCase(Locale.ROOT);
e = "#" + name;
}
}
}
else if (attacker.getType().name() != null) {
e = "#" + attacker.getType().name().toLowerCase(Locale.ROOT);
}
}
else {
EntityDamageEvent.DamageCause cause = damage.getCause();
if (cause.equals(EntityDamageEvent.DamageCause.FIRE)) {
e = "#fire";
}
else if (cause.equals(EntityDamageEvent.DamageCause.FIRE_TICK)) {
if (!skip) {
e = "#fire";
}
}
else if (cause.equals(EntityDamageEvent.DamageCause.LAVA)) {
e = "#lava";
}
else if (cause.equals(EntityDamageEvent.DamageCause.BLOCK_EXPLOSION)) {
e = "#explosion";
}
else if (cause.equals(EntityDamageEvent.DamageCause.MAGIC)) {
e = "#magic";
}
}
if (entity instanceof ArmorStand) {
Location entityLocation = entity.getLocation();
if (!Config.getConfig(entityLocation.getWorld()).ITEM_TRANSACTIONS) {
entityLocation.setY(entityLocation.getY() + 0.99);
Block block = entityLocation.getBlock();
Queue.queueBlockBreak(e, block.getState(), Material.ARMOR_STAND, null, (int) entityLocation.getYaw());
}
return;
}
EntityType entity_type = entity.getType();
if (e.length() == 0) {
// assume killed self
if (!skip) {
if (!(entity instanceof Player) && entity_type.name() != null) {
// Player player = (Player)entity;
// e = player.getName();
e = "#" + entity_type.name().toLowerCase(Locale.ROOT);
}
else if (entity instanceof Player) {
e = entity.getName();
}
}
}
if (e.startsWith("#wither")) {
e = "#wither";
}
if (e.startsWith("#enderdragon")) {
e = "#enderdragon";
}
if (e.startsWith("#primedtnt") || e.startsWith("#tnt")) {
e = "#tnt";
}
if (e.startsWith("#lightning")) {
e = "#lightning";
}
if (e.length() > 0) {
List<Object> data = new ArrayList<>();
List<Object> age = new ArrayList<>();
List<Object> tame = new ArrayList<>();
List<Object> attributes = new ArrayList<>();
List<Object> details = new ArrayList<>();
List<Object> info = new ArrayList<>();
EntityType type = entity_type;
// Basic LivingEntity attributes
details.add(entity.getRemoveWhenFarAway());
details.add(entity.getCanPickupItems());
if (entity instanceof Ageable) {
Ageable ageable = (Ageable) entity;
age.add(ageable.getAge());
age.add(ageable.getAgeLock());
age.add(ageable.isAdult());
age.add(ageable.canBreed());
age.add(null);
}
if (entity instanceof Tameable) {
Tameable tameable = (Tameable) entity;
tame.add(tameable.isTamed());
if (tameable.isTamed()) {
if (tameable.getOwner() != null) {
tame.add(tameable.getOwner().getName());
}
}
}
if (entity instanceof Attributable) {
Attributable attributable = entity;
for (Attribute attribute : Attribute.values()) {
AttributeInstance attributeInstance = attributable.getAttribute(attribute);
if (attributeInstance != null) {
List<Object> attributeData = new ArrayList<>();
List<Object> attributeModifiers = new ArrayList<>();
attributeData.add(attributeInstance.getAttribute());
attributeData.add(attributeInstance.getBaseValue());
for (AttributeModifier modifier : attributeInstance.getModifiers()) {
attributeModifiers.add(modifier.serialize());
}
attributeData.add(attributeModifiers);
attributes.add(attributeData);
}
}
}
if (entity instanceof Creeper) {
Creeper creeper = (Creeper) entity;
info.add(creeper.isPowered());
}
else if (entity instanceof Enderman) {
Enderman enderman = (Enderman) entity;
info.add(null);
try {
info.add(enderman.getCarriedBlock().getAsString());
}
catch (Exception endermanException) {
}
}
else if (entity instanceof IronGolem) {
IronGolem irongolem = (IronGolem) entity;
info.add(irongolem.isPlayerCreated());
}
else if (entity instanceof Cat) {
Cat cat = (Cat) entity;
info.add(cat.getCatType());
info.add(cat.getCollarColor());
}
else if (entity instanceof Fox) {
Fox fox = (Fox) entity;
info.add(fox.getFoxType());
info.add(fox.isSitting());
}
else if (entity instanceof Panda) {
Panda panda = (Panda) entity;
info.add(panda.getMainGene());
info.add(panda.getHiddenGene());
}
else if (entity instanceof Pig) {
Pig pig = (Pig) entity;
info.add(pig.hasSaddle());
}
else if (entity instanceof Sheep) {
Sheep sheep = (Sheep) entity;
info.add(sheep.isSheared());
info.add(sheep.getColor());
}
else if (entity instanceof MushroomCow) {
MushroomCow mushroomCow = (MushroomCow) entity;
info.add(mushroomCow.getVariant());
}
else if (entity instanceof Skeleton) {
info.add(null);
}
else if (entity instanceof Slime) {
Slime slime = (Slime) entity;
info.add(slime.getSize());
}
else if (entity instanceof Parrot) {
Parrot parrot = (Parrot) entity;
info.add(parrot.getVariant());
}
else if (entity instanceof TropicalFish) {
TropicalFish tropicalFish = (TropicalFish) entity;
info.add(tropicalFish.getBodyColor());
info.add(tropicalFish.getPattern());
info.add(tropicalFish.getPatternColor());
}
else if (entity instanceof Phantom) {
Phantom phantom = (Phantom) entity;
info.add(phantom.getSize());
}
else if (entity instanceof AbstractVillager) {
AbstractVillager abstractVillager = (AbstractVillager) entity;
List<Object> recipes = new ArrayList<>();
for (MerchantRecipe merchantRecipe : abstractVillager.getRecipes()) {
List<Object> recipe = new ArrayList<>();
List<Object> ingredients = new ArrayList<>();
List<Object> itemMap = new ArrayList<>();
ItemStack item = merchantRecipe.getResult().clone();
List<List<Map<String, Object>>> metadata = ItemMetaHandler.seralize(item, item.getType(), null, 0);
item.setItemMeta(null);
itemMap.add(item.serialize());
itemMap.add(metadata);
recipe.add(itemMap);
recipe.add(merchantRecipe.getUses());
recipe.add(merchantRecipe.getMaxUses());
recipe.add(merchantRecipe.hasExperienceReward());
for (ItemStack ingredient : merchantRecipe.getIngredients()) {
itemMap = new ArrayList<>();
item = ingredient.clone();
metadata = ItemMetaHandler.seralize(item, item.getType(), null, 0);
item.setItemMeta(null);
itemMap.add(item.serialize());
itemMap.add(metadata);
ingredients.add(itemMap);
}
recipe.add(ingredients);
recipe.add(merchantRecipe.getVillagerExperience());
recipe.add(merchantRecipe.getPriceMultiplier());
recipes.add(recipe);
}
if (abstractVillager instanceof Villager) {
Villager villager = (Villager) abstractVillager;
info.add(villager.getProfession());
info.add(villager.getVillagerType());
info.add(recipes);
info.add(villager.getVillagerLevel());
info.add(villager.getVillagerExperience());
}
else {
info.add(null);
info.add(null);
info.add(recipes);
}
}
else if (entity instanceof Raider) {
Raider raider = (Raider) entity;
info.add(raider.isPatrolLeader());
if (entity instanceof Spellcaster) {
Spellcaster spellcaster = (Spellcaster) entity;
info.add(spellcaster.getSpell());
}
}
else if (entity instanceof Wolf) {
Wolf wolf = (Wolf) entity;
info.add(wolf.isSitting());
info.add(wolf.getCollarColor());
}
else if (entity instanceof ZombieVillager) {
ZombieVillager zombieVillager = (ZombieVillager) entity;
info.add(zombieVillager.isBaby());
info.add(zombieVillager.getVillagerProfession());
}
else if (entity instanceof Zombie) {
Zombie zombie = (Zombie) entity;
info.add(zombie.isBaby());
info.add(null);
info.add(null);
}
else if (entity instanceof AbstractHorse) {
AbstractHorse abstractHorse = (AbstractHorse) entity;
info.add(null);
info.add(null);
info.add(abstractHorse.getDomestication());
info.add(abstractHorse.getJumpStrength());
info.add(abstractHorse.getMaxDomestication());
info.add(null);
info.add(null);
if (entity instanceof Horse) {
Horse horse = (Horse) entity;
info.add(null);
ItemStack saddle = horse.getInventory().getSaddle();
if (saddle != null) {
info.add(saddle.serialize());
}
else {
info.add(null);
}
info.add(horse.getColor());
info.add(horse.getStyle());
ItemStack horseArmor = horse.getInventory().getArmor();
if (horseArmor != null) {
ItemStack armor = horseArmor.clone();
ItemMeta itemMeta = armor.getItemMeta();
Color color = null;
if (itemMeta instanceof LeatherArmorMeta) {
LeatherArmorMeta meta = (LeatherArmorMeta) itemMeta;
color = meta.getColor();
meta.setColor(null);
armor.setItemMeta(meta);
}
info.add(armor.serialize());
if (color != null) {
info.add(color.serialize());
}
else {
info.add(null);
}
}
else {
info.add(null);
info.add(null);
}
}
else if (entity instanceof ChestedHorse) {
ChestedHorse chestedHorse = (ChestedHorse) entity;
info.add(chestedHorse.isCarryingChest());
if (entity instanceof Llama) {
Llama llama = (Llama) entity;
ItemStack decor = llama.getInventory().getDecor();
if (decor != null) {
info.add(decor.serialize());
}
else {
info.add(null);
}
info.add(llama.getColor());
}
}
}
else {
BukkitAdapter.ADAPTER.getEntityMeta(entity, info);
}
data.add(age);
data.add(tame);
data.add(info);
data.add(entity.isCustomNameVisible());
data.add(entity.getCustomName());
data.add(attributes);
data.add(details);
if (!(entity instanceof Player)) {
Queue.queueEntityKill(e, entity.getLocation(), data, type);
}
else {
Queue.queuePlayerKill(e, entity.getLocation(), entity.getName());
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onEntityDeath(EntityDeathEvent event) {
LivingEntity entity = event.getEntity();
@ -73,400 +514,6 @@ public final class EntityDeathListener extends Queue implements Listener {
return;
}
if (Config.getConfig(entity.getWorld()).ENTITY_KILLS) {
EntityDamageEvent damage = entity.getLastDamageCause();
if (damage != null) {
String e = "";
boolean skip = true;
if (!Config.getConfig(entity.getWorld()).SKIP_GENERIC_DATA || (!(entity instanceof Zombie) && !(entity instanceof Skeleton))) {
skip = false;
}
if (damage instanceof EntityDamageByEntityEvent) {
EntityDamageByEntityEvent attack = (EntityDamageByEntityEvent) damage;
Entity attacker = attack.getDamager();
if (attacker instanceof Player) {
Player player = (Player) attacker;
e = player.getName();
}
else if (attacker instanceof AbstractArrow) {
AbstractArrow arrow = (AbstractArrow) attacker;
ProjectileSource shooter = arrow.getShooter();
if (shooter instanceof Player) {
Player player = (Player) shooter;
e = player.getName();
}
else if (shooter instanceof LivingEntity) {
EntityType entityType = ((LivingEntity) shooter).getType();
if (entityType != null) { // Check for MyPet plugin
String name = entityType.name().toLowerCase(Locale.ROOT);
e = "#" + name;
}
}
}
else if (attacker instanceof ThrownPotion) {
ThrownPotion potion = (ThrownPotion) attacker;
ProjectileSource shooter = potion.getShooter();
if (shooter instanceof Player) {
Player player = (Player) shooter;
e = player.getName();
}
else if (shooter instanceof LivingEntity) {
EntityType entityType = ((LivingEntity) shooter).getType();
if (entityType != null) { // Check for MyPet plugin
String name = entityType.name().toLowerCase(Locale.ROOT);
e = "#" + name;
}
}
}
else if (attacker.getType().name() != null) {
e = "#" + attacker.getType().name().toLowerCase(Locale.ROOT);
}
}
else {
EntityDamageEvent.DamageCause cause = damage.getCause();
if (cause.equals(EntityDamageEvent.DamageCause.FIRE)) {
e = "#fire";
}
else if (cause.equals(EntityDamageEvent.DamageCause.FIRE_TICK)) {
if (!skip) {
e = "#fire";
}
}
else if (cause.equals(EntityDamageEvent.DamageCause.LAVA)) {
e = "#lava";
}
else if (cause.equals(EntityDamageEvent.DamageCause.BLOCK_EXPLOSION)) {
e = "#explosion";
}
else if (cause.equals(EntityDamageEvent.DamageCause.MAGIC)) {
e = "#magic";
}
}
if (entity instanceof ArmorStand) {
Location entityLocation = entity.getLocation();
if (!Config.getConfig(entityLocation.getWorld()).ITEM_TRANSACTIONS) {
entityLocation.setY(entityLocation.getY() + 0.99);
Block block = entityLocation.getBlock();
Queue.queueBlockBreak(e, block.getState(), Material.ARMOR_STAND, null, (int) entityLocation.getYaw());
}
return;
}
EntityType entity_type = entity.getType();
if (e.length() == 0) {
// assume killed self
if (!skip) {
if (!(entity instanceof Player) && entity_type.name() != null) {
// Player player = (Player)entity;
// e = player.getName();
e = "#" + entity_type.name().toLowerCase(Locale.ROOT);
}
else if (entity instanceof Player) {
e = entity.getName();
}
}
}
if (e.startsWith("#wither")) {
e = "#wither";
}
if (e.startsWith("#enderdragon")) {
e = "#enderdragon";
}
if (e.startsWith("#primedtnt") || e.startsWith("#tnt")) {
e = "#tnt";
}
if (e.startsWith("#lightning")) {
e = "#lightning";
}
if (e.length() > 0) {
List<Object> data = new ArrayList<>();
List<Object> age = new ArrayList<>();
List<Object> tame = new ArrayList<>();
List<Object> attributes = new ArrayList<>();
List<Object> details = new ArrayList<>();
List<Object> info = new ArrayList<>();
EntityType type = entity_type;
// Basic LivingEntity attributes
details.add(entity.getRemoveWhenFarAway());
details.add(entity.getCanPickupItems());
if (entity instanceof Ageable) {
Ageable ageable = (Ageable) entity;
age.add(ageable.getAge());
age.add(ageable.getAgeLock());
age.add(ageable.isAdult());
age.add(ageable.canBreed());
age.add(null);
}
if (entity instanceof Tameable) {
Tameable tameable = (Tameable) entity;
tame.add(tameable.isTamed());
if (tameable.isTamed()) {
if (tameable.getOwner() != null) {
tame.add(tameable.getOwner().getName());
}
}
}
if (entity instanceof Attributable) {
Attributable attributable = entity;
for (Attribute attribute : Attribute.values()) {
AttributeInstance attributeInstance = attributable.getAttribute(attribute);
if (attributeInstance != null) {
List<Object> attributeData = new ArrayList<>();
List<Object> attributeModifiers = new ArrayList<>();
attributeData.add(attributeInstance.getAttribute());
attributeData.add(attributeInstance.getBaseValue());
for (AttributeModifier modifier : attributeInstance.getModifiers()) {
attributeModifiers.add(modifier.serialize());
}
attributeData.add(attributeModifiers);
attributes.add(attributeData);
}
}
}
if (entity instanceof Creeper) {
Creeper creeper = (Creeper) entity;
info.add(creeper.isPowered());
}
else if (entity instanceof Enderman) {
Enderman enderman = (Enderman) entity;
info.add(null);
try {
info.add(enderman.getCarriedBlock().getAsString());
}
catch (Exception endermanException) {
}
}
else if (entity instanceof IronGolem) {
IronGolem irongolem = (IronGolem) entity;
info.add(irongolem.isPlayerCreated());
}
else if (entity instanceof Cat) {
Cat cat = (Cat) entity;
info.add(cat.getCatType());
info.add(cat.getCollarColor());
}
else if (entity instanceof Fox) {
Fox fox = (Fox) entity;
info.add(fox.getFoxType());
info.add(fox.isSitting());
}
else if (entity instanceof Panda) {
Panda panda = (Panda) entity;
info.add(panda.getMainGene());
info.add(panda.getHiddenGene());
}
else if (entity instanceof Pig) {
Pig pig = (Pig) entity;
info.add(pig.hasSaddle());
}
else if (entity instanceof Sheep) {
Sheep sheep = (Sheep) entity;
info.add(sheep.isSheared());
info.add(sheep.getColor());
}
else if (entity instanceof MushroomCow) {
MushroomCow mushroomCow = (MushroomCow) entity;
info.add(mushroomCow.getVariant());
}
else if (entity instanceof Skeleton) {
info.add(null);
}
else if (entity instanceof Slime) {
Slime slime = (Slime) entity;
info.add(slime.getSize());
}
else if (entity instanceof Parrot) {
Parrot parrot = (Parrot) entity;
info.add(parrot.getVariant());
}
else if (entity instanceof TropicalFish) {
TropicalFish tropicalFish = (TropicalFish) entity;
info.add(tropicalFish.getBodyColor());
info.add(tropicalFish.getPattern());
info.add(tropicalFish.getPatternColor());
}
else if (entity instanceof Phantom) {
Phantom phantom = (Phantom) entity;
info.add(phantom.getSize());
}
else if (entity instanceof AbstractVillager) {
AbstractVillager abstractVillager = (AbstractVillager) entity;
List<Object> recipes = new ArrayList<>();
for (MerchantRecipe merchantRecipe : abstractVillager.getRecipes()) {
List<Object> recipe = new ArrayList<>();
List<Object> ingredients = new ArrayList<>();
List<Object> itemMap = new ArrayList<>();
ItemStack item = merchantRecipe.getResult().clone();
List<List<Map<String, Object>>> metadata = ItemMetaHandler.seralize(item, item.getType(), null, 0);
item.setItemMeta(null);
itemMap.add(item.serialize());
itemMap.add(metadata);
recipe.add(itemMap);
recipe.add(merchantRecipe.getUses());
recipe.add(merchantRecipe.getMaxUses());
recipe.add(merchantRecipe.hasExperienceReward());
for (ItemStack ingredient : merchantRecipe.getIngredients()) {
itemMap = new ArrayList<>();
item = ingredient.clone();
metadata = ItemMetaHandler.seralize(item, item.getType(), null, 0);
item.setItemMeta(null);
itemMap.add(item.serialize());
itemMap.add(metadata);
ingredients.add(itemMap);
}
recipe.add(ingredients);
recipe.add(merchantRecipe.getVillagerExperience());
recipe.add(merchantRecipe.getPriceMultiplier());
recipes.add(recipe);
}
if (abstractVillager instanceof Villager) {
Villager villager = (Villager) abstractVillager;
info.add(villager.getProfession());
info.add(villager.getVillagerType());
info.add(recipes);
info.add(villager.getVillagerLevel());
info.add(villager.getVillagerExperience());
}
else {
info.add(null);
info.add(null);
info.add(recipes);
}
}
else if (entity instanceof Raider) {
Raider raider = (Raider) entity;
info.add(raider.isPatrolLeader());
if (entity instanceof Spellcaster) {
Spellcaster spellcaster = (Spellcaster) entity;
info.add(spellcaster.getSpell());
}
}
else if (entity instanceof Wolf) {
Wolf wolf = (Wolf) entity;
info.add(wolf.isSitting());
info.add(wolf.getCollarColor());
}
else if (entity instanceof ZombieVillager) {
ZombieVillager zombieVillager = (ZombieVillager) entity;
info.add(zombieVillager.isBaby());
info.add(zombieVillager.getVillagerProfession());
}
else if (entity instanceof Zombie) {
Zombie zombie = (Zombie) entity;
info.add(zombie.isBaby());
info.add(null);
info.add(null);
}
else if (entity instanceof AbstractHorse) {
AbstractHorse abstractHorse = (AbstractHorse) entity;
info.add(null);
info.add(null);
info.add(abstractHorse.getDomestication());
info.add(abstractHorse.getJumpStrength());
info.add(abstractHorse.getMaxDomestication());
info.add(null);
info.add(null);
if (entity instanceof Horse) {
Horse horse = (Horse) entity;
info.add(null);
ItemStack saddle = horse.getInventory().getSaddle();
if (saddle != null) {
info.add(saddle.serialize());
}
else {
info.add(null);
}
info.add(horse.getColor());
info.add(horse.getStyle());
ItemStack horseArmor = horse.getInventory().getArmor();
if (horseArmor != null) {
ItemStack armor = horseArmor.clone();
ItemMeta itemMeta = armor.getItemMeta();
Color color = null;
if (itemMeta instanceof LeatherArmorMeta) {
LeatherArmorMeta meta = (LeatherArmorMeta) itemMeta;
color = meta.getColor();
meta.setColor(null);
armor.setItemMeta(meta);
}
info.add(armor.serialize());
if (color != null) {
info.add(color.serialize());
}
else {
info.add(null);
}
}
else {
info.add(null);
info.add(null);
}
}
else if (entity instanceof ChestedHorse) {
ChestedHorse chestedHorse = (ChestedHorse) entity;
info.add(chestedHorse.isCarryingChest());
if (entity instanceof Llama) {
Llama llama = (Llama) entity;
ItemStack decor = llama.getInventory().getDecor();
if (decor != null) {
info.add(decor.serialize());
}
else {
info.add(null);
}
info.add(llama.getColor());
}
}
}
else {
BukkitAdapter.ADAPTER.getEntityMeta(entity, info);
}
data.add(age);
data.add(tame);
data.add(info);
data.add(entity.isCustomNameVisible());
data.add(entity.getCustomName());
data.add(attributes);
data.add(details);
if (!(entity instanceof Player)) {
Queue.queueEntityKill(e, entity.getLocation(), data, type);
}
else {
Queue.queuePlayerKill(e, entity.getLocation(), entity.getName());
}
}
}
}
logEntityDeath(entity, null);
}
}

View File

@ -18,5 +18,21 @@ public final class PlayerCommandListener extends Queue implements Listener {
long timestamp = System.currentTimeMillis() / 1000L;
Queue.queuePlayerCommand(player, event.getMessage(), timestamp);
}
/*
if (Config.getGlobal().ENTITY_KILLS && player.hasPermission("bukkit.command.kill")) {
EntityDeathListener.parseEntityKills(event.getMessage());
}
*/
}
/*
@EventHandler(priority = EventPriority.MONITOR)
public void onServerCommand(ServerCommandEvent event) {
if (Config.getGlobal().ENTITY_KILLS && event.getCommand().toLowerCase(Locale.ROOT).startsWith("kill")) {
EntityDeathListener.parseEntityKills(event.getCommand());
}
}
*/
}