Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class LegacyWeapons
- implements Listener
- {
- public static Main plugin;
- public HashMap<String, Long> cooldown = new HashMap();
- public int cooldownTime = 20;
- public LegacyWeapons(Main instance) {
- plugin = instance;
- }
- @EventHandler
- public void onLegacyWeaponClick(PlayerInteractEvent event) {
- final Player player = event.getPlayer();
- Sound gh = Sound.WITHER_HURT;
- if ((player.getInventory().getItemInHand().getType() == Material.IRON_AXE) &&
- (player.getItemInHand().getItemMeta().hasDisplayName()) &&
- ((event.getAction() == Action.RIGHT_CLICK_AIR) || (event.getAction() == Action.RIGHT_CLICK_BLOCK)) &&
- (player.getItemInHand().getItemMeta().getDisplayName().equalsIgnoreCase(ChatColor.RED + "Hyper Axe"))) {
- if (cooldown.containsKey(player.getName())) {
- long diff = (System.currentTimeMillis() - cooldown.get(player.getName())) / 1000;
- if (diff < cooldownTime) {
- 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!");
- return;
- }
- this.cooldown.put(player.getName(), Long.valueOf(System.currentTimeMillis()));
- }
- this.cooldown.put(player.getName(), Long.valueOf(System.currentTimeMillis()));
- if (player.getItemInHand().getItemMeta().getDisplayName().equalsIgnoreCase(ChatColor.RED + "Hyper Axe")) {
- Sound sound = Sound.WITHER_HURT;
- player.getWorld().playEffect(player.getLocation(), Effect.STEP_SOUND, Material.IRON_BLOCK.getId());
- player.getWorld().playEffect(player.getLocation(), Effect.STEP_SOUND, Material.LAPIS_BLOCK.getId());
- player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED,
- 120, 3));
- player.sendMessage(ChatColor.AQUA + "[Hyper Axe] " + ChatColor.GRAY + "You used " + ChatColor.LIGHT_PURPLE + "Hyper Speed!");
- }
- }
- Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
- public void run() {
- if (LegacyWeapons.this.cooldown.containsKey(player.getName())) {
- LegacyWeapons.this.cooldown.remove(player.getName());
- player.sendMessage(ChatColor.AQUA + "[Hyper Axe] " + ChatColor.YELLOW + "[Recharged]" + ChatColor.GREEN + " Hyper Speed");
- /* */
- /* */
- /* */ {
- /* */ }
- /* */ }
- }},400);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement