Advertisement
Guest User

Error

a guest
Jan 2nd, 2014
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. public class LegacyWeapons
  2. implements Listener
  3. {
  4. public static Main plugin;
  5. public HashMap<String, Long> cooldown = new HashMap();
  6. public int cooldownTime = 20;
  7. public LegacyWeapons(Main instance) {
  8. plugin = instance;
  9. }
  10.  
  11. @EventHandler
  12. public void onLegacyWeaponClick(PlayerInteractEvent event) {
  13. final Player player = event.getPlayer();
  14. Sound gh = Sound.WITHER_HURT;
  15. if ((player.getInventory().getItemInHand().getType() == Material.IRON_AXE) &&
  16. (player.getItemInHand().getItemMeta().hasDisplayName()) &&
  17. ((event.getAction() == Action.RIGHT_CLICK_AIR) || (event.getAction() == Action.RIGHT_CLICK_BLOCK)) &&
  18. (player.getItemInHand().getItemMeta().getDisplayName().equalsIgnoreCase(ChatColor.RED + "Hyper Axe"))) {
  19. if (cooldown.containsKey(player.getName())) {
  20. long diff = (System.currentTimeMillis() - cooldown.get(player.getName())) / 1000;
  21. if (diff < cooldownTime) {
  22. player.sendMessage(ChatColor.AQUA + "[Hyper Axe]" + ChatColor.LIGHT_PURPLE + " Hyper Speed" + ChatColor.YELLOW + " is still on a " + ChatColor.LIGHT_PURPLE + (this.cooldownTime - diff) + "s" + ChatColor.YELLOW + " cooldown!");
  23. return;
  24. }
  25. this.cooldown.put(player.getName(), Long.valueOf(System.currentTimeMillis()));
  26. }
  27.  
  28. this.cooldown.put(player.getName(), Long.valueOf(System.currentTimeMillis()));
  29. if (player.getItemInHand().getItemMeta().getDisplayName().equalsIgnoreCase(ChatColor.RED + "Hyper Axe")) {
  30. Sound sound = Sound.WITHER_HURT;
  31. player.getWorld().playEffect(player.getLocation(), Effect.STEP_SOUND, Material.IRON_BLOCK.getId());
  32. player.getWorld().playEffect(player.getLocation(), Effect.STEP_SOUND, Material.LAPIS_BLOCK.getId());
  33.  
  34. player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED,
  35. 120, 3));
  36. player.sendMessage(ChatColor.AQUA + "[Hyper Axe] " + ChatColor.GRAY + "You used " + ChatColor.LIGHT_PURPLE + "Hyper Speed!");
  37. }
  38.  
  39. }
  40.  
  41.  
  42.  
  43.  
  44.  
  45. Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
  46. public void run() {
  47. if (LegacyWeapons.this.cooldown.containsKey(player.getName())) {
  48. LegacyWeapons.this.cooldown.remove(player.getName());
  49. player.sendMessage(ChatColor.AQUA + "[Hyper Axe] " + ChatColor.YELLOW + "[Recharged]" + ChatColor.GREEN + " Hyper Speed");
  50. /* */
  51. /* */
  52. /* */ {
  53. /* */ }
  54. /* */ }
  55. }},400);
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement