From 00423da2efacb2b1239f73a2293753cb088331f1 Mon Sep 17 00:00:00 2001 From: Brianna Date: Mon, 8 Jul 2019 15:42:19 -0400 Subject: [PATCH] Clean up. --- .../listeners/DeathListeners.java | 18 +++++++++--------- .../ultimatestacker/lootables/LootManager.java | 7 +++++++ 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/songoda/ultimatestacker/listeners/DeathListeners.java b/src/main/java/com/songoda/ultimatestacker/listeners/DeathListeners.java index 13ef55f..3ad2c8d 100644 --- a/src/main/java/com/songoda/ultimatestacker/listeners/DeathListeners.java +++ b/src/main/java/com/songoda/ultimatestacker/listeners/DeathListeners.java @@ -2,7 +2,9 @@ package com.songoda.ultimatestacker.listeners; import com.songoda.ultimatestacker.UltimateStacker; import com.songoda.ultimatestacker.utils.settings.Setting; +import org.bukkit.Bukkit; import org.bukkit.Material; +import org.bukkit.entity.Llama; import org.bukkit.entity.Pig; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -10,6 +12,7 @@ import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.inventory.ItemStack; +import java.util.ArrayList; import java.util.List; public class DeathListeners implements Listener { @@ -23,21 +26,18 @@ public class DeathListeners implements Listener { @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onEntityDeath(EntityDeathEvent event) { List items = Setting.CUSTOM_DROPS.getBoolean() - ? instance.getLootManager().getDrops(event.getEntity()) : event.getDrops(); + ? instance.getLootManager().getDrops(event.getEntity()) : new ArrayList<>(); if (items.size() != 0) { - if (event.getEntity() instanceof Pig && ((Pig) event.getEntity()).hasSaddle()) - event.getEntity().getWorld().dropItemNaturally(event.getEntity().getLocation(), - new ItemStack(Material.SADDLE)); - event.getDrops().clear(); + + for (ItemStack item : items) { + if (item == null) continue; + event.getEntity().getWorld().dropItemNaturally(event.getEntity().getLocation(), item); + } } else items = event.getDrops(); - for (ItemStack item : items) { - if (item == null) continue; - event.getEntity().getWorld().dropItemNaturally(event.getEntity().getLocation(), item); - } if (instance.getEntityStackManager().isStacked(event.getEntity())) instance.getEntityStackManager().getStack(event.getEntity()) diff --git a/src/main/java/com/songoda/ultimatestacker/lootables/LootManager.java b/src/main/java/com/songoda/ultimatestacker/lootables/LootManager.java index 47ec577..3e00f39 100644 --- a/src/main/java/com/songoda/ultimatestacker/lootables/LootManager.java +++ b/src/main/java/com/songoda/ultimatestacker/lootables/LootManager.java @@ -312,6 +312,13 @@ public class LootManager { .setAllowLootingEnchant(false).build()) .build())); + // Add Llama. + addLootable(new Lootable(EntityType.LLAMA, + new LootBuilder() + .setMaterial(Material.LEATHER) + .setMin(0) + .setMax(2).build())); + // Add Zombie Horse. addLootable(new Lootable(EntityType.ZOMBIE_HORSE, new LootBuilder()