Clean up.

This commit is contained in:
Brianna 2019-07-08 15:42:19 -04:00
parent 442334d898
commit 00423da2ef
2 changed files with 16 additions and 9 deletions

View File

@ -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<ItemStack> 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();
} else
items = event.getDrops();
for (ItemStack item : items) {
if (item == null) continue;
event.getEntity().getWorld().dropItemNaturally(event.getEntity().getLocation(), item);
}
} else
items = event.getDrops();
if (instance.getEntityStackManager().isStacked(event.getEntity()))
instance.getEntityStackManager().getStack(event.getEntity())

View File

@ -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()