Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.cooper.AusBrawl;
- import java.util.HashMap;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.Effect;
- import org.bukkit.Material;
- import org.bukkit.entity.Player;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.block.Action;
- import org.bukkit.event.entity.EntityDamageEvent;
- import org.bukkit.event.player.PlayerInteractEvent;
- import org.bukkit.inventory.ItemStack;
- public class Agility implements Listener{
- public static Main plugin;
- public Agility(Main instance) {
- plugin = instance;
- }
- public HashMap<String, Long> cooldown = new HashMap<String, Long>();
- public int cooldownTime = 1;
- @EventHandler
- public void onPlayerInteract(PlayerInteractEvent event) {
- final Player player = event.getPlayer();
- if(player.getEquipment().getHelmet().getType() == Material.MOB_SPAWNER){
- if(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK){
- if(player.getInventory().getItemInHand().getType() == Material.AIR){
- if (cooldown.containsKey(player.getName())) {
- long diff = (System.currentTimeMillis() - cooldown.get(player.getName())) / 1000;
- if (diff < cooldownTime) {
- 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!");
- return;
- }
- cooldown.put(player.getName(), System.currentTimeMillis());
- }
- cooldown.put(player.getName(), System.currentTimeMillis());
- if(player.getEquipment().getHelmet().getType() == Material.MOB_SPAWNER){
- ItemStack agilityhelmet = new ItemStack(Material.MOB_SPAWNER);
- if(player.hasPermission("aMod.Agility")){
- if ((event.getAction() == Action.LEFT_CLICK_BLOCK) || (event.getAction() == Action.LEFT_CLICK_AIR)) {
- if(player.getInventory().getItemInHand().getType() == Material.AIR){
- player.setVelocity(player.getEyeLocation().getDirection().multiply(1.4));
- player.getWorld().playEffect(player.getLocation(), Effect.STEP_SOUND,Material.SNOW_BLOCK.getId());
- player.setFallDistance(0);
- player.sendMessage(ChatColor.RED + "[Ability]" + ChatColor.YELLOW + " You used" + ChatColor.LIGHT_PURPLE + " Aerial Leap" + ChatColor.YELLOW + "!");
- }
- }
- }
- Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
- public void run() {
- if (Agility.this.cooldown.containsKey(player.getName())) {
- Agility.this.cooldown.remove(player.getName());
- player.sendMessage(ChatColor.RED + "[C] " + ChatColor.YELLOW + "[Recharged]" + ChatColor.LIGHT_PURPLE + " Leap");
- /* */
- /* */
- /* */ {
- /* */ }
- /* */ }
- }},20);
- }
- }
- }
- }
- }
- public void enabled(boolean b) {
- // TODO Auto-generated method stub
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement