EasyCooldown

Discussion in 'Resources' started by Tirelessly, Feb 8, 2013.

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

    bloodless2010

    Thanks for this, I'm gonna use this to stop a dupe bug with icon menus! :D
     
  2. Offline

    CeramicTitan

    sorry to necro this, but how would I create a bypass, for instance if a player has a certain permission, it doesn't check their cooldown status?
     
  3. Offline

    Tirelessly

    if(Cooldowns.tryCooldown(player, "cooldown", 15000) || player.hasPermission("cooldown.bypass")){
    ...
    }
     
    CeramicTitan likes this.
  4. Offline

    CeramicTitan

    Thanks! That idea never came to mind.
     
  5. Offline

    Tirelessly

    SkillSam

    Code:
    public void removeCooldown(String cooldownName, String player){
    PlayerCooldown pc = new PlayerCooldown(cooldownName, player, 0); //0 is arbitrary value
          Iterator<PlayerCooldown> it = Cooldown.cooldowns.iterator(); //You're going to want to make cooldowns public or replace that with a getter method
          //This section prevents duplicate cooldowns
          while(it.hasNext()) {
            PlayerCooldown iterated = it.next();
            if(iterated.getPlayerName().equalsIgnoreCase(pc.getPlayerName())) {
                if(iterated.getCooldownName().equalsIgnoreCase(pc.getCooldownName())) {
                  it.remove();
                }
            }
          }
    }
    
     
  6. Offline

    Comphenix

    In my version you have a couple of options - if you've only got a couple of different cooldowns, I'd would do something like the following:
    Code:java
    1. Cooldowns.setCooldown(player, "my_first_cooldown", 0);
    2. Cooldowns.setCooldown(player, "my_second", 0);

    If you want to reset a whole range of cooldowns, I'd recommend adding this method to the cooldown class:
    Code:java
    1. /**
    2. * Remove any cooldowns associated with the given player.
    3. * @param player - the player we will reset.
    4. */
    5. public static void removeCooldowns(Player player) {
    6. cooldowns.row(player.getName()).clear();
    7. }
     
Thread Status:
Not open for further replies.

Share This Page