Advertisement
Guest User

LMSEvents Class

a guest
Jul 5th, 2014
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. package me.LYSwitch.lms;
  2.  
  3. import me.LYSwitch.main.main;
  4.  
  5. import org.bukkit.Bukkit;
  6. import org.bukkit.ChatColor;
  7. import org.bukkit.Location;
  8. import org.bukkit.Sound;
  9. import org.bukkit.World;
  10. import org.bukkit.entity.Player;
  11. import org.bukkit.event.EventHandler;
  12. import org.bukkit.event.Listener;
  13. import org.bukkit.event.entity.PlayerDeathEvent;
  14. import org.bukkit.event.player.PlayerEvent;
  15. import org.bukkit.event.player.PlayerTeleportEvent;
  16. import org.bukkit.potion.PotionEffect;
  17. import org.bukkit.potion.PotionEffectType;
  18.  
  19. public class LMSEvent implements Listener {
  20. public main plugin;
  21.  
  22. public LMSEvent(main instance) {
  23. plugin = instance;
  24. }
  25.  
  26. @EventHandler
  27. //The protection when you're spawned in
  28. public void LMSprot(PlayerTeleportEvent e) {
  29. Player p = e.getPlayer();
  30. if (plugin.lmsarena.contains(p.getName())) {
  31. p.addPotionEffect(new PotionEffect(
  32. PotionEffectType.DAMAGE_RESISTANCE, 10 * 20, 5));
  33. p.sendMessage(ChatColor.RED
  34. + "You have damage resistance for 10 seconds. RUN");
  35. }
  36. }
  37.  
  38. @EventHandler
  39. //The death msg
  40. public void LMSmsg(PlayerDeathEvent e) {
  41. Player p = (Player) e.getEntity();
  42. if (plugin.lmsarena.contains(p.getName())) {
  43. Bukkit.getServer().broadcastMessage(
  44. p.getName() + " has been slain in the LMS arena.");
  45. plugin.lmsarena.remove(p.getName());
  46. plugin.lmshost.remove(p.getName());
  47. plugin.lmsjoin.remove(p.getName());
  48. }
  49. }
  50.  
  51. @EventHandler
  52. //The lms end and lms end msg.
  53. public void LMSend(PlayerEvent e) {
  54. Player p = e.getPlayer();
  55. World w = p.getWorld();
  56. Location ploc = p.getLocation();
  57. int x = 0;
  58. int z = 50;
  59. int y = 0;
  60. if (plugin.lmsarena.size() == 1) {
  61. if(plugin.lmsarena.contains(p.getName())){
  62. Bukkit.getServer().broadcastMessage(
  63. ChatColor.RED + p.getName() + " has won the LMS!");
  64. p.teleport(new Location(w, x, y, z));
  65. p.playSound(ploc, Sound.FIREWORK_LARGE_BLAST2, 1, 5);
  66. p.sendMessage(ChatColor.GRAY + "Congratulations. You have been awarded 50 credits.");
  67. plugin.lmsarena.remove(p.getName());
  68. plugin.lmshost.remove(p.getName());
  69. plugin.lmsjoin.remove(p.getName());
  70. }
  71. }
  72. }
  73.  
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement