Advertisement
Guest User

Error

a guest
Dec 26th, 2013
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.33 KB | None | 0 0
  1. package me.cooper.AusBrawl;
  2.  
  3. import java.util.HashMap;
  4.  
  5. import org.bukkit.Bukkit;
  6. import org.bukkit.ChatColor;
  7. import org.bukkit.Effect;
  8. import org.bukkit.Material;
  9. import org.bukkit.entity.Player;
  10. import org.bukkit.event.EventHandler;
  11. import org.bukkit.event.Listener;
  12. import org.bukkit.event.block.Action;
  13. import org.bukkit.event.entity.EntityDamageEvent;
  14. import org.bukkit.event.player.PlayerInteractEvent;
  15. import org.bukkit.inventory.ItemStack;
  16.  
  17. public class Agility implements Listener{
  18.  
  19. public static Main plugin;
  20.  
  21.  
  22. public Agility(Main instance) {
  23. plugin = instance;
  24. }
  25.  
  26. public HashMap<String, Long> cooldown = new HashMap<String, Long>();
  27.  
  28. public int cooldownTime = 1;
  29.  
  30. @EventHandler
  31. public void onPlayerInteract(PlayerInteractEvent event) {
  32. final Player player = event.getPlayer();
  33. if(player.getEquipment().getHelmet().getType() == Material.MOB_SPAWNER){
  34. if(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK){
  35. if(player.getInventory().getItemInHand().getType() == Material.AIR){
  36. if (cooldown.containsKey(player.getName())) {
  37. long diff = (System.currentTimeMillis() - cooldown.get(player.getName())) / 1000;
  38. if (diff < cooldownTime) {
  39. player.sendMessage(ChatColor.RED + "[C]" + ChatColor.LIGHT_PURPLE + " Aerial Leap" + ChatColor.YELLOW + " is still on a " + ChatColor.LIGHT_PURPLE + (cooldownTime - diff) + "s" + ChatColor.YELLOW + " cooldown!");
  40. return;
  41. }
  42.  
  43. cooldown.put(player.getName(), System.currentTimeMillis());
  44.  
  45. }
  46.  
  47. cooldown.put(player.getName(), System.currentTimeMillis());
  48. if(player.getEquipment().getHelmet().getType() == Material.MOB_SPAWNER){
  49. ItemStack agilityhelmet = new ItemStack(Material.MOB_SPAWNER);
  50. if(player.hasPermission("aMod.Agility")){
  51. if ((event.getAction() == Action.LEFT_CLICK_BLOCK) || (event.getAction() == Action.LEFT_CLICK_AIR)) {
  52. if(player.getInventory().getItemInHand().getType() == Material.AIR){
  53. player.setVelocity(player.getEyeLocation().getDirection().multiply(1.4));
  54. player.getWorld().playEffect(player.getLocation(), Effect.STEP_SOUND,Material.SNOW_BLOCK.getId());
  55. player.setFallDistance(0);
  56. player.sendMessage(ChatColor.RED + "[Ability]" + ChatColor.YELLOW + " You used" + ChatColor.LIGHT_PURPLE + " Aerial Leap" + ChatColor.YELLOW + "!");
  57. }
  58. }
  59. }
  60. Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
  61. public void run() {
  62. if (Agility.this.cooldown.containsKey(player.getName())) {
  63. Agility.this.cooldown.remove(player.getName());
  64. player.sendMessage(ChatColor.RED + "[C] " + ChatColor.YELLOW + "[Recharged]" + ChatColor.LIGHT_PURPLE + " Leap");
  65. /* */
  66. /* */
  67. /* */ {
  68. /* */ }
  69. /* */ }
  70. }},20);
  71.  
  72. }
  73. }
  74. }
  75. }
  76. }
  77.  
  78. public void enabled(boolean b) {
  79. // TODO Auto-generated method stub
  80.  
  81. }
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement