Advertisement
Guest User

Linked source code

a guest
Aug 14th, 2015
246
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package YOUR_PACKAGE_HERE;
  2.  
  3. import org.bukkit.Bukkit;
  4. import org.bukkit.entity.Damageable;
  5. import org.bukkit.entity.Player;
  6. import org.bukkit.event.EventHandler;
  7. import org.bukkit.event.Listener;
  8. import org.bukkit.event.entity.EntityDamageEvent;
  9. import org.bukkit.event.entity.FoodLevelChangeEvent;
  10. import org.bukkit.event.entity.PlayerDeathEvent;
  11.  
  12. public class PlayerListener implements Listener {
  13.  
  14. @EventHandler
  15. public void onPlayerDamage(EntityDamageEvent e) {
  16. Damageable player = (Player) e.getEntity();
  17. double damage = e.getDamage();
  18. double health = player.getHealth() - damage;
  19. for(Player p : Bukkit.getServer().getOnlinePlayers()) {
  20. p.setHealth(health);
  21. }
  22. }
  23.  
  24. @EventHandler
  25. public void onHungerLoss(FoodLevelChangeEvent e) {
  26. if (e.getEntity() instanceof Player) {
  27. int h = e.getFoodLevel();
  28. for(Player player : Bukkit.getServer().getOnlinePlayers()) {
  29. player.setFoodLevel(h);
  30. }
  31. }
  32. }
  33.  
  34. @SuppressWarnings("deprecation")
  35. @EventHandler
  36. public void onPlayerDeath(PlayerDeathEvent e) {
  37. Player player = (Player) e.getEntity();
  38. for(Player p : Bukkit.getServer().getOnlinePlayers()) {
  39. p.setHealth(2);
  40. player.setHealth(0);
  41. }
  42. }
  43. }
Advertisement
RAW Paste Data Copied
Advertisement