Advertisement
jayhillx

sendPlayerDeathMessage

Feb 22nd, 2021
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. static Timer timer = new Timer();
  2.  
  3. public static void sendDeathMessage(PlayerEntity player) {
  4. for (int counter = 0; counter < 1; counter++) {
  5. timer.schedule(new TimerTask() {
  6. public void run() {
  7. if (player.getServer() != null) {
  8. for (net.minecraft.entity.player.ServerPlayerEntity serverPlayerEntity : player.getServer().getPlayerList().getPlayers()) {
  9. if (player.getMaxHealth() >= 2 && player.getMaxHealth() <= 18) {
  10. float maxHealth = player.getMaxHealth();
  11. int lives = (int) (10 - (maxHealth / 2));
  12. XLifeHealthMod.LOGGER.info(player.getGameProfile().getName());
  13. if (lives >= 2) {
  14. SendMessage.sendMessage(serverPlayerEntity, TextFormatting.RED + player.getGameProfile().getName() + " has " + lives + " lives remaining . . .");
  15. } else if (lives == 1) {
  16. SendMessage.sendMessage(serverPlayerEntity, TextFormatting.RED + player.getGameProfile().getName() + " has one life remaining . . .");
  17. }
  18. } else {
  19. SendMessage.sendMessage(serverPlayerEntity, TextFormatting.RED + player.getGameProfile().getName() + " has been eliminated . . .");
  20. }
  21. }
  22. }
  23. }
  24. }, 8);
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement