[UTIL] CooldownManager - Easy Cooldown Management

Discussion in 'Resources' started by Dealyise, Aug 11, 2014.

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

    Dealyise

    Heya!
    Today I am sharing my Cooldown Manager. I am using it in my plugins and it works well.
    I saw some other guys here sharing their Cooldown Class, but in my opinion it wasn't "well coded".
    Cooldown Manager comes with the following features:
    • Intelligent Cooldown System for Commands
    • Semi-automatic Cooldown System for Commands
    • Semi-automatic Cooldown System for Anything you need
    • Intelligent Cache System
    • Player Cache, does not store in HashMaps. Creates player files in your plugin folder
    • Lightweight, does not crash the server or stuff like that
    Suggestions? Then just tell me them, I will try to apply them!
    Version: 1.1
    -------------------
    Changelog:
    v.1.1:
    • *Fixed Cache System
    • *Fixed Login/Logout Methods
    • *Source Adjustments
    • +Added Intelligent Cache System: You can choose between temporary Cache Mode or permanent Cache Mode
    • -Removed Comments, which didn't belong to Cooldown Manager
    v1.0:
    • Release
    DOWNLOAD: v1.1


    -------------------
    Usage:
    First of all, you need to init the Cooldown Class @ onEnable():
    (Easy Management, everything is semi-automatic)
    Code:java
    1. //Cooldown cd = new Cooldown(PluginInstance)
    2. Cooldown cd = new Cooldown(this);

    (Auto. Management, checks player's Command Cooldown auto.)
    Code:java
    1. //new Cooldown(PluginInstance, boolean activateIntelligentCommandCooldown, boolean toggleCacheMode, int cooldownValue, String timeType (s = Second/s, m = Minute/s, h = Hour/s, d = Day/s)
    2. Cooldown cd = new Cooldown(this, true, true, 5, "s");
    3. //addCommand(Your Command/s here)
    4. cd.addCommand("hello", "test", "spawn", "tp");


    Add Cooldown to player (without Command):
    Code:java
    1. //activateCooldown(Player p, int timeValue, String timeType);
    2. cd.activateCooldown(player, 5, "s");


    Add Cooldown to player (with Command):
    Code:java
    1. //activateCooldown(Player p, String command, int timeValue, String timeType);
    2. cd.activateCooldown(player, "hello", 5, "s");

    Check Cooldown of player (without Command):
    Code:java
    1. //cd.hasCooldown(Player)
    2. if(cd.hasCooldown(p)){
    3. //has cooldown
    4. }else{
    5. //has no cooldown
    6. }


    Check Cooldown of player (with Command):
    Code:java
    1. //cd.hasCooldown(Player, String command)
    2. if(cd.hasCooldown(p, "hello")){
    3. //has cooldown
    4. }else{
    5. //has no cooldown
    6. }


    Get Cooldown of player (without Command):
    Code:java
    1. //cd.returnCooldown(Player)
    2. String cdText = cd.returnCooldown(p);
    3. p.sendMessage("Stop! You still have a cooldown! Time Left: " + cdText);


    Get Cooldown of player (with Command):
    Code:java
    1. //cd.returnCooldown(Player, String command)
    2. String cdText = cd.returnCooldown(p, "hello");
    3. p.sendMessage("Stop! You still have a cooldown! Time Left: " + cdText);


    Example Usage:
    PasteBin


    <Edited by bwfcwalshy: Removed MediaFire link.>

    Cooldown Manager - Intelligent Systems
    • Intelligent Cooldown System for Commands
    This option offers an automatic Cooldown System for Commands. Whenever Player does a specific command you've registered, it will check if a Cooldown is given or not.
    • Intelligent Cache Mode
    This option offers an automatic Cache System. When set to false, it will keep Players in a temporary cache. Player's get removed from it when they log out. When set to true, it will keep Players in a permanent cache. Player's get removed from it when they don't have any Cooldowns within logout. If there's a Cooldown left, it will keep the Player in Cache until the Cooldown expired. When the Player leaves again and there's no Cooldown left, he will be removed from Cache.

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

    LCastr0

    I have posted a simpler cooldown once... Though this one saves it. I cannot look the source now but tomorrow I will.
     
  3. Offline

    Garris0n

    I swear if I look at the source and see one scheduler...

    Edit: *breathes sigh of happiness*

    You need to fix some of those variable names, though. Here.
     
  4. Offline

    Dealyise

    Garris0n
    Haha :D
    Yeah, I will edit that ofc. Thanks again :)

    Edit: I just edited the source and there are some changes.
     
  5. Offline

    Garris0n

    I still see quite a few variable names starting with capital letters. Also, constants are supposed to have their words separated by underscores LIKE_THIS.
     
    Dealyise likes this.
  6. Offline

    LordVakar

    Just wondering, why do you use label in your example usage?
     
    Garris0n likes this.
  7. Offline

    Dealyise

    LordVakar
    I don't know, works like cmd... I always used label for any reason. :D
    Garris0n
    Do you have Skype? I would like to get some help with it, I actually never worked with Variable Names enough. I know some basics, but not everything. Would be cool to receive some help with it.
     
  8. Offline

    mazentheamazin

  9. Offline

    Goblom

    Dont forget this one! Cooldowns (with Events)

    Dealyise Why are you using MediaFire... Its alot easier to use Github Gist, that way everyone can see changes made to this resource.

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

    Dealyise

    Goblom
    I will think about that.
    Thanks for your suggestion.
     
  11. Offline

    Muhammadazka

    nice
     
    Last edited: Jan 3, 2017
  12. Offline

    Ula492

    Does anyone have a download to this? I've been looking for something like this for a while now.
     
  13. Offline

    Dealyise

  14. Offline

    Ula492

Thread Status:
Not open for further replies.

Share This Page