Event cooldowns. [Need help]

Discussion in 'Plugin Development' started by _BrodieC, Jul 3, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    _BrodieC

    I need help with Cooldowns!
     
  2. Offline

    THEREDBARON24

    add the object that the cooldown is active on into a list. Then. run a task later that removes that object. On whatever event. check to see if the cooldown list has the object, if true, deny. If false, then do this^
     
  3. Offline

    Dubehh

    _BrodieC
    What have you tried? Where did it go wrong?
     
  4. Offline

    _BrodieC

    ArrayList<Player> resistcooldown = new ArrayList<Player>();
    @EventHandler
    public void riposte(PlayerInteractEvent e) {
    final Player p = e.getPlayer();
    if(resistcooldown.contains(p) && e.getAction() == Action.RIGHT_CLICK_AIR)
    if(Armour.getKit(p).equals(ClassType.IRON)) {
    if(utilPlayer.hasSwords(p)) {
    p.sendMessage( ChatColor.DARK_AQUA + "Templar> " +ChatColor.GRAY + "You can not use " + ChatColor.AQUA + "Resist");
    }else if (e.getAction() == Action.RIGHT_CLICK_AIR) {
    if(Armour.getKit(p).equals(ClassType.IRON)) {
    if(utilPlayer.hasSwords(p)) {

    p.sendMessage(ChatColor.DARK_AQUA + "Tempar> " + ChatColor.GRAY + "You have used" + ChatColor.AQUA + " Resist");
    p.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 100,3));
    resistcooldown.add(p);
    Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(main, new Runnable() {
    public void run() {
    resistcooldown.remove(p);
    p.sendMessage(ChatColor.RED + "Templar> " + ChatColor.GRAY + "Recharged " + ChatColor.AQUA + "Resist");
    }
    }, 200L);
    }
    }
    }

    Is this kinda right?
    ArrayList<Player> resistcooldown = new ArrayList<Player>();
    @EventHandler
    public void riposte(PlayerInteractEvent e) {
    final Player p = e.getPlayer();
    if(resistcooldown.contains(p) && e.getAction() == Action.RIGHT_CLICK_AIR)
    if(Armour.getKit(p).equals(ClassType.IRON)) {
    if(utilPlayer.hasSwords(p)) {
    p.sendMessage( ChatColor.DARK_AQUA + "Templar> " +ChatColor.GRAY + "You can not use " + ChatColor.AQUA + "Resist");
    }else if (e.getAction() == Action.RIGHT_CLICK_AIR) {
    if(Armour.getKit(p).equals(ClassType.IRON)) {
    if(utilPlayer.hasSwords(p)) {

    p.sendMessage(ChatColor.DARK_AQUA + "Tempar> " + ChatColor.GRAY + "You have used" + ChatColor.AQUA + " Resist");
    p.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 100,3));
    resistcooldown.add(p);
    Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(main, new Runnable() {
    public void run() {
    resistcooldown.remove(p);
    p.sendMessage(ChatColor.RED + "Templar> " + ChatColor.GRAY + "Recharged " + ChatColor.AQUA + "Resist");
    }
    }, 200L);
    }
    }
    }

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  5. Offline

    THEREDBARON24

    Appears to be correct. I can't be 100% sure, however, the general idea is correct.
     
  6. Offline

    Hexxed_

    I always use List<Player> name = new ArrayList<Player>(); instead of ArrayList<Player> name = new ArrayList<Player>();. Im not sure if that will change anything though.
     
Thread Status:
Not open for further replies.

Share This Page