Advertisement
Guest User

Untitled

a guest
Nov 30th, 2012
376
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 KB | None | 0 0
  1. @EventHandler
  2. public void onDamage(EntityDamageByEntityEvent ev) {
  3. if ((ev.getDamager() instanceof Projectile)) {
  4. Projectile bullit = (Projectile)ev.getDamager();
  5. if ((bullit.getShooter() instanceof Player && ev.getEntity() instanceof Player)) {
  6. Player pl = (Player)ev.getEntity();
  7. Player to = (Player)bullit.getShooter();
  8. String toPlayer = "";
  9. if(pl.getHealth()%2 != 0) {
  10. for(int i = 0; i < (pl.getHealth()-1)/2; i++) {
  11. toPlayer = toPlayer + "❤";
  12. }
  13. toPlayer = toPlayer + "♥";
  14. }
  15. else {
  16. for(int i = 0; i < pl.getHealth()/2; i++) {
  17. toPlayer = toPlayer + "❤";
  18. }
  19. }
  20. ChatColor prefix;
  21. if(toPlayer.length() > 7)
  22. prefix = ChatColor.GREEN;
  23. else if(toPlayer.length() > 4)
  24. prefix = ChatColor.YELLOW;
  25. else
  26. prefix = ChatColor.RED;
  27. to.sendMessage(ChatColor.GOLD+"Leben von "+ChatColor.DARK_GREEN+pl.getName()+ChatColor.GOLD+": "+prefix+toPlayer);
  28. }
  29. }
  30. if (ev.getDamager() instanceof Player && ev.getEntity() instanceof Player) {
  31. Player pl = (Player)ev.getEntity();
  32. Player to = (Player)ev.getDamager();
  33. String toPlayer = "";
  34. if(pl.getHealth()%2 != 0) {
  35. for(int i = 0; i < (pl.getHealth()-1)/2; i++) {
  36. toPlayer = toPlayer + "❤";
  37. }
  38. toPlayer = toPlayer + "♥";
  39. }
  40. else {
  41. for(int i = 0; i < pl.getHealth()/2; i++) {
  42. toPlayer = toPlayer + "❤";
  43. }
  44. }
  45. ChatColor prefix;
  46. if(toPlayer.length() > 7)
  47. prefix = ChatColor.GREEN;
  48. else if(toPlayer.length() > 4)
  49. prefix = ChatColor.YELLOW;
  50. else
  51. prefix = ChatColor.RED;
  52. to.sendMessage(ChatColor.GOLD+"Leben von "+ChatColor.DARK_GREEN+pl.getName()+ChatColor.GOLD+": "+prefix+toPlayer);
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement