How would I make death messages colored? Like the original minecraft death messages, but colored. Also, how do I make some one have a set color. So, in the playerchatevent if a player is op they would have a red name, is it possible for the player to have a red name in the death messages as well? I hope I explained it well enough
Yes, Code: @EventHandler public void onDeath(PlayerDeathEvent event){ Player player = event.getPlayer(); String message = event.getMessage(); //or getDeathMessage I'm not sure String finalmsg = message.replaceAll(player.getName(), player.getDisplayName()); event.setMessage(finalmsg); // or setDeathMessage(), also not sure }
CaptainBern That looks like it will work, but how can I make it so the messages are colored like "player1 &4has slain player2"
How would I replace multiple things? Like the color code in the death message after I replaced the player name
Limeth That is not what I meant, I should've been a bit more descriptive. I meant like I already use this to change the player name Code:java String message = event.getDeathMessage(); String deathmsg = message.replaceAll(player.getName(), player.getDisplayName()); Now I want to replace like "player1 has been slain by player2" I want to replace it with "player1 &5has been slain by &r player2
xCyanide Oops, my bad. Why don't you just create your own death messages? Code:text ChatColor msgColor = ChatColor.YELLOW;ChatColor killerColor = ChatColor.GREEN;ChatColor victimColor = ChatColor.RED;Player victim = event.getPlayer();Player killer = victim.getKiller();String victimName = victim.getName();String killerName = killer.getName();event.setDeathMessage(victimColor + victimName + msgColor + " has been slain by " + killerColor + killerName)