diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index e5474941d..4aff23dd5 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -1,5 +1,6 @@ package com.gmail.nossr50.listeners; +import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.Material; import org.bukkit.block.Block; @@ -29,8 +30,10 @@ import org.bukkit.inventory.ItemStack; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.chat.ChatManager; import com.gmail.nossr50.config.Config; +import com.gmail.nossr50.datatypes.MobHealthbarType; import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.skills.AbilityType; import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.locale.LocaleLoader; @@ -58,6 +61,21 @@ public class PlayerListener implements Listener { this.plugin = plugin; } + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onPlayerDeathHighest(PlayerDeathEvent event) { + String deathMessage = event.getDeathMessage(); + PlayerProfile profile = UserManager.getPlayer(event.getEntity()).getProfile(); + + if (profile.getMobHealthbarType() == MobHealthbarType.HEARTS && deathMessage.contains("❤❤")) { + deathMessage.replaceFirst("❤+", ChatColor.RESET + "a mob"); + } + else if (profile.getMobHealthbarType() == MobHealthbarType.BAR && deathMessage.contains("■■■■■■■■■■")) { + deathMessage.replace("■■■■■■■■■■", ChatColor.RESET + "a mob"); + } + + event.setDeathMessage(deathMessage); + } + /** * Monitor PlayerDeath events. *