diff --git a/src/cl/mastercode/DamageIndicator/DIMain.java b/src/cl/mastercode/DamageIndicator/DIMain.java index a1217a0..a1ad1e1 100644 --- a/src/cl/mastercode/DamageIndicator/DIMain.java +++ b/src/cl/mastercode/DamageIndicator/DIMain.java @@ -38,7 +38,6 @@ import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; import org.bukkit.plugin.java.JavaPlugin; -import org.checkerframework.checker.nullness.qual.NonNull; import java.util.Iterator; import java.util.Map; @@ -197,7 +196,7 @@ public void reloadMessages() { messages = YamlConfiguration.loadConfiguration(getDataFolder().toPath().resolve("messages.yml").toFile()); } - public @NonNull BukkitAudiences adventure() { + public BukkitAudiences adventure() { if (this.adventure == null) { throw new IllegalStateException("Tried to access Adventure when the plugin was disabled!"); } diff --git a/src/cl/mastercode/DamageIndicator/listener/BloodListener.java b/src/cl/mastercode/DamageIndicator/listener/BloodListener.java index 3484318..decda63 100644 --- a/src/cl/mastercode/DamageIndicator/listener/BloodListener.java +++ b/src/cl/mastercode/DamageIndicator/listener/BloodListener.java @@ -43,6 +43,7 @@ import org.bukkit.util.Vector; import java.util.HashSet; import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Random; @@ -56,6 +57,7 @@ public class BloodListener implements Listener { private static final String BLOOD_NAME = "di-blood"; private static final String DISABLED_BLOOD = "DI-DISABLED-BLOOD"; + private static final ItemStack[] BLOOD_ITEMS = new ItemStack[]{new ItemStack(Material.CRIMSON_ROOTS), new ItemStack(Material.FIRE_CORAL_FAN), new ItemStack(Material.RED_DYE)}; private final DIMain plugin; private final Map bloodItems = new LinkedHashMap<>(); private final Set disabledEntities = new HashSet<>(); @@ -165,11 +167,15 @@ public void onPlayerDeath(PlayerDeathEvent e) { return; } for (int i = 0; i < 14; i++) { - ItemStack is = new ItemStack(new ItemStack(Material.RED_DYE)); + ItemStack is = BLOOD_ITEMS[i % 3]; ItemMeta meta = is.getItemMeta(); - meta.setDisplayName(BLOOD_NAME); - is.setItemMeta(meta); - Item item = e.getEntity().getWorld().dropItemNaturally(e.getEntity().getLocation(), is); + // check if meta was already set for item on the array + if (!meta.hasDisplayName()) { + meta.setDisplayName(BLOOD_NAME); + meta.setLore(List.of(String.valueOf(i))); + is.setItemMeta(meta); + } + Item item = e.getEntity().getWorld().dropItemNaturally(e.getEntity().getEyeLocation(), is); item.setPickupDelay(Integer.MAX_VALUE); item.setVelocity(new Vector(random.nextDouble() * 0.1, 0.4, random.nextDouble() * 0.1)); bloodItems.put(item, System.currentTimeMillis());