[GEN/MECH] Cooldowns v1.1 - Configurable Cooldowns and Warmups [1060]

Discussion in 'Inactive/Unsupported Plugins' started by krinsdeath, Jul 4, 2011.

  1. Offline

    krinsdeath

    Cooldowns v1.0.0 - Configurable command cooldowns and warmups​
    Wiki
    Version 1.1 is now released!
    The plugin has gone through an insane amount of revision. I honestly didn't think the project would grow to be this large, or this complicated, but there you go. The new feature list is astounding by comparison. Version 1.0.0 requires CraftBukkit 1000, and I recommend PermissionsBukkit for managing the groups.​

    In version 1.1, the config.yml has added the key "priority" to the groups nodes. As a result, you can either delete your current configurations to get the new nodes, or edit them by hand (their location is provided in the default config.yml farther down this post). The priority node will determine which group a user ends up in if more than one group is detected by the plugin (due to inheritance or whatever reason). This node is optional, but recommended. The higher a group's priority, the more likely the user is to be set to that group. Furthermore, the plugin now checks the player's group every time they log in or the plugins are reloaded.​
    In addition to the priority node, the plugin now checks for groups at "cooldowns.[groupname]" and "group.[groupname]"​
    If you have multiple plugins which use the latter format, this plugin will duplicate their functionality (provided your groups in config.yml are the same name), in an effort to reduce node clutter.​

    Requirements
    • CraftBukkit build 1000 (or later)
    Optional (Recommended)
    • PermissionsBukkit 1.2 (or later)
    Want me to include your language? Send me a language.yml with (at the very least) localization information for all of the default messages, and I'll package it into the jar!

    Originally requested by @GFlow in this thread

    For more verbose installation/usage instructions, visit the wiki.

    Description: Configurable command cooldowns and warmups, based on 'groups'.

    Basic Usage: Drop Cooldowns.jar into your plugin directory, and go!
    config.yml (open)

    Code:
    plugin:
        # put the worlds you want to manage cooldowns and warmups in here
        worlds:
          - 'world'
          - 'world_nether'
        default_locale: 'en_US'
        available_locales: [en_US]
        # colors: true will enable logging in color (this will only work on non-windows platforms)
        colors: true
    
    groups:
        # -----------------
        default:
            priority: 1
            # prefix applies to messages sent by this plugin to the player, such as status messages
            # it does not change chat settings, and should not interfere with any other plugins
            prefix: '[default] '
            interrupts:
                movement: true
                damage: true
                command: true
            globals:
                cooldowns: true
                warmups: true
            # _all_ will match all commands (for a root node), or all arguments for a sub-node
            # _self_ will match the command sender's name
            # all values specified are in seconds.
            commands:
                warmup:
                    _all_: 5
                cooldown:
                    _all_: 5
        # -----------------
        user:
            priority: 2
            prefix: '[user] '
            interrupts:
                movement: true
                damage: true
                command: true
            globals:
                cooldowns: true
                warmups: true
            commands:
                warmup:
                    home: 2
                    warp:
                        home: 2
                        _all_: 5
                cooldown:
                    home: 60
                    warp:
                        home: 60
                        _all_: 120
        # -----------------
        admin:
            priority: 3
            prefix: '[admin] '
            interrupts:
                movement: false
                damage: false
                command: true
            globals:
                cooldowns: true
                warmups: true
            commands:
                warmup:
                    kill: 2
                    tp:
                        _self_: 2
                        _all_: 2
                    time: 2
                cooldown:
                    kill: 5
                    tp:
                        _self_: 60
                        _all_: 120
                    time: 5
    

    Localization (open)

    Code:
    # set any value to "null" to disable it entirely.
    plugin:
        enabled: "Enabled."
        disabled: "Disabled."
        language: "American English"
        locale_not_found: "No such locale exists."
        locale_changed: "Language changed to American English."
        help:
          - '&b/<cmd> help &f- &aDisplays this help menu.'
          - '&b/<cmd> loc [option] &f- &aSets your locale to'
          - '--- &athe option provided, or lists available locales.'
          - '&b/<cmd> setup &f- &aShows your settings.'
          - '&b/<cmd> &f- &aLists your current cooldowns.'
        setup:
          - 'Your settings: (American English)'
          - '&aGlobals&f:'
          - '-- Warmups... &a<global_warm>'
          - '-- Cooldowns... &a<global_cool>'
          - '&aInterrupts&f:'
          - '-- Movement... &a<movement>'
          - '-- Commands... &a<commands>'
          - '-- Damage... &a<damage> &f(&cnot implemented&f)'
    
    # set any _generic_ key to null to disable it
    # ------- #
    # warmups #
    # ------- #
    warmup:
        start:
            _generic_: "'&b<cmd>&f' is now warming up. (&b<wu>&f)"
        status:
            _generic_: "'&b<cmd>&f' is warming up. (&b<wu>&f)"
        done:
            _generic_: "You are no longer warming up '&b<cmd>&f'."
        cancel:
            _generic_: "&cYou cancelled '&3<cmd>&c'..."
            _movement_: "&cYou moved and cancelled '&3<cmd>&c'..."
            _damage_: "&cYou took damage, which cancelled '&3<cmd>&c'..."
    
    # --------- #
    # cooldowns #
    # --------- #
    cooldown:
        start:
            _generic_: null
            # "'&b<cmd>&f' is now cooling down. (&b<cd>&f)"
        status:
            _generic_: "'&b<cmd>&f' is cooling down. (&b<cd>&f)"
        done:
            _generic_: "You are ready to use '&b<cmd>&f' again."
    

    Permissions (open)

    Permissions flags are equivalent to the group names you set in the config.yml, plus the "cooldowns." prefix. By default, the permissions are as follows:
    cooldowns.default - Applies the configuration settings for the default group.
    cooldowns.users - Applies the configuration settings for the users group.
    cooldowns.admins - Applies the configuration settings for the admins group.

    Furthermore, if you use PermissionsBukkit and rely on inheritance, you'll need to cancel the previous group's permission:
    Code:
    groups:
        default:
            permissions:
                cooldowns.default: true
        user:
            permissions:
                cooldowns.users: true
                cooldowns.default: false
            inheritance:
            - default
        admin:
            permissions:
                cooldowns.admins: true
                cooldowns.users: false
            inheritance:
            - user
    

    Screenshots (open)

    [​IMG]
    [​IMG]

    Commands:
    • /cooldowns - Without any parameters will print a list of currently cooling commands.
    • /cooldowns locale [option] - The option flag will attempt to set that user's locale to the option he provides. If no option is provided, it will print a list of localizations available.
    • /cooldowns setup - Show the settings for the user who sends the command
    • /cooldowns help - Prints a brief help message detailing the above information.
    • /cd and /cooldown are both aliases for /cooldowns, and will work interchangeably.
    Features:
    • Completely configurable warmups, including being able to cancel commands by taking damage, moving, or issuing another command.
    • Configurable cooldowns, including global and local cooldowns, that persist across server restarts and reloads.
    • Localizations, including options inside the localization to configure messages for commands my plugin doesn't know about.
    Issues: v1.0.0 is newly released. I haven't yet found bugs.
    Feedback and error reports are very helpful. Be thorough when you tell me what's wrong! This includes your server.log, lists of plugins (and their versions), which build of craftbukkit you are running, any modifications you've made to the configuration, plus any other information you feel is relevant. More information = faster bug fixes!

    Changelog:
    Version 1.0.0:
    • Complete rework of the project, from the ground up
    • Includes both local and global warmups and cooldowns
    • More configuration, more stability, more power
    • Verbose localizations, including custom status messages per command
    Version 0.5.0:
    • Massive restructuring of the plugin, which included moving it to Maven.
    • The configuration file has dropped in complexity, yet offers most of the same functionality.
    • Local cooldowns are simply not realistic. As such, I've made commands local in the sense that only commands listed for the user in my configuration will be cooled or warmed.
    • All cooldowns are global. If a command has a 10 second cooldown, all commands [registered to my plugin] are unusable for 10 seconds.
    • Removed the ability to cancel warmups by moving. If I find some way to easily configure options for this, I'll add it back in.
    Changelog (~0.4.0a) (open)

    Version 0.4.0a:
    • Localizations for every conceivable command variation
    • Warm ups and cooldowns can be interrupted by damage, and can work on different timers
    • Won't claim anything outlandish like it's stable, as this is a massive amount of work and I can't really test it all on my own.
    • Hopefully you're satisfied!
    Version 0.3.0a:
    • Restructured plugin
    • Added command (/cooldowns)
    • Increased localization
    • Warmups and cast times are even more configurable(?)
    Version 0.2.2:
    • Added warm up periods
    • General cleanup
    • New class to parse messages contained in locale files
    • TODO
      1. Warm up reset on player damage
      2. Warm up reset when player types a new command
    Version 0.2.1:
    • Added Localizations
    • Fixed cooldown messages
    • Added users.yml for persistent localization per user
    • TODO
      1. Hook permissions for localizations?
      2. Warm up/cast times for commands
      3. Configurable warm up/cast times on player damage
    Version 0.2.0:
    • Added Block cooldowns
    • Changed config format
    • More comments
    Version 0.1.0:
    • Initial release
     
    Taranis01 likes this.
  2. Offline

    krinsdeath

    Are you using Permissions, or using the default configuration?

    I think I know what the problem is, actually. My default configuration doesn't map any commands to the "Users" group. The moment I logged in to my local server after turning my op status off I got a null pointer.

    Fix will be up in a short time. Thanks for the help! :D

    edit: New JAR is up! Replace your old one and reload, and it should fix the NullPointer.
     
  3. Offline

    Likwidface

    permissions. but aside from that, nothing out of the ordinary. I've messed with it for hours on end.
     
  4. Offline

    Djrowling

    I know this is probably a very stupid question but i'm getting this error.

    20:23:18 [SEVERE] Exception in thread "Timer-0"
    20:23:18 [SEVERE] java.lang.NullPointerException
    20:23:18 [SEVERE] at net.krinsoft.cooldowns.CDTimer.runScheduledCommands(CDTimer.java:28)

    I know it's probably related to the config which at this point i'm having problems understanding, i'll eventually get it. Anyway here's my config. Any help?

    Default:
    damage: none
    move_cancel: true
    cooldowns: global
    chat_prefix: '&3[<group>:<user>]'
    commands:
    home: [5, 5]
    spawn: [5, 5]
    blocks:
     
  5. Offline

    krinsdeath

    @Djrowling - It's hard to say. When does this error occur? Once every second? Or only when you schedule a command/are cooling down?

    Are you getting any other errors? From your config, I don't think the problem lies there (unless there's some indentation problem I can't see, try enclosing your config settings in code blocks)

    note: if you capitalize the group name in the config, you need to capitalize the group name in the permissions node for your groups. Also, if you aren't using permissions, the default group names (Users and Admins) need to remain unchanged (you can freely edit any of the subkeys)

    edit: How can I make the config file easier to follow? The project grew in scope really quickly, so I kind of haphazardly threw keys in there for the setup. Is there anything you would change?
     
  6. Offline

    Djrowling

    __________________________________________

    @krinsdeath As soon as i login it gives me the error.

    20:53:34 [SEVERE] Exception in thread "Timer-0"
    20:53:34 [SEVERE] java.lang.NullPointerException
    20:53:34 [SEVERE] at net.krinsoft.cooldowns.CDTimer.runScheduledCommands(C
    DTimer.java:28)
    20:53:34 [SEVERE] at net.krinsoft.cooldowns.CDTimer.run(CDTimer.java:17)
    20:53:34 [SEVERE] at java.util.TimerThread.mainLoop(Unknown Source)
    20:53:34 [SEVERE] at java.util.TimerThread.run(Unknown Source)

    It could possibly my permissions? I gave 'cooldowns.Default' in permissions to the Default class. I'm really unsure of the proble. Thank-you for dedicating your time to helping me btw, i know it can get annoying being pestered by others.
     
  7. Offline

    krinsdeath

    That's.. weird. I don't get any errors whatsoever, even doing things that (given my current coding status) should give errors.

    What build of CraftBukkit and Permissions? And what other plugins are you using?
     
  8. Offline

    Djrowling

    Bookworm, Factions, McMMO, BorderArea, Essentials, EssentialsChat, EssentialsSpawn, FoundDiamonds, NoCheat, Permissions, WorldEdit, DeathTpPlus, McDOCs, Tips, Spyer, SpyerAdmin, MonsterBox.

    I couldn't imagine it would be a contrasting plugin but you never know.
    (Build 953 & Permissions 3.0)

    EDIT: I guess i'll just have to tamper with it.
     
  9. Offline

    Likwidface

    I have warp set to Users on a 1 cooldown 5 warmup timer and it tells me 5 seconds until execute a warp named 'home'
    i say '/warp home'
    so it says 'warp will execute in 5 seconds'
    then at the end of 5 seconds it says 'warp executed' and gives me info as though I had only typed '/warp'
    same for typing /warp anything.
    movement is set to interrupt, and that has no effect on the countdown/warmup.
     
  10. Offline

    krinsdeath

    I've tried with exactly your configuration, empty commands/empty blocks, permissions and no permissions, and I can't get that error to happen.

    I can get a few null pointers from using invalid values in the config, but with how yours is set up, I can't figure it out. You shouldn't be seeing that error.

    @Likwidface - I haven't hooked the movement event, so move-canceling doesn't work yet. As for what you just described, I'll try to replicate it.. Your node tree looks like this, I presume?

    Code:
    groups:
      Users:
        damage: none
        move_cancel: true
        cooldowns: global
        chat_prefix: 'etc'
        commands:
          warp: [1, 5]
        blocks:
    
    note: I apologize for the inconvenience of the plugin being kind of shitty. This is my first one plugin and my first foray into Java in general, so bare with me. :(
     
  11. Offline

    Likwidface

    yep. looks like that, but damage is set to interrupt.
     
  12. Offline

    krinsdeath

    Alright, I found your problem. I forgot to pass the arguments to commands without sub-keys. Very simple fix, and it should be good! Source is updated on github and the new JAR is up now!

    It addresses your issue, @Likwidface

    As for Djrowling, I'm still looking around to figure out why it's doing that. It makes no sense and I can't replicate it.
     
  13. Offline

    Taranis01

    @krinsdeath
    could u make cooldowns more silence? :)
    I get 2 lines of text every command im using, even if it hasn't cooldowns+
    my suggestion: stop writing logs for commands that aren't cooldown commands.
    and toggleable via config: logs for cooldwons-commands
     
  14. Offline

    Likwidface

    Now it works - damage and movement will cancel the warmup. But if I type /warp 1, warp 1, spawn spawn spawn -
    both are on a [1, 6] timer and I type them while its warming up, the command breaks. It ends up saying "warp will execute in 6 seconds" but it does not execute at all. Even 20 seconds later, I can move to cancel the warmup that never executed the command. :(

    Definitely have made some real progress here so far! Keep up the amazing work.
     
  15. Offline

    krinsdeath

    I'm not sure I understand what you mean. You type that as one string/line? As in:

    "/warp 1, warp 1, spawn spawn spawn"

    Or do you mean you type:

    /warp 1
    /warp 1
    /spawn
    /spawn
    /spawn

    And it breaks everything and explodes
     
  16. Offline

    blokzeil1

    Hello,

    I have your plugin
    but there is one big problem!
    when i config the plugin and reload the server, the server did a restart and not one 1 time but 5 times.
    when i delete the command and did a reload it works fine
    the command is:
    t spawn
    cooldowns: local
    chat_prefix: '&5[<group>:<user>]'
    commands:
    t:
    spawn: 3
    blocks:
    # material: [place_cooldown, break_cooldown]
    # -- note: break cooldown not implemented

    I hope you can help me
     
  17. Offline

    krinsdeath

    Each value contained under the commands section needs to be a list:

    Code:
    commands:
      t:
        spawn: [3, 0]
    
    If a list is not found, it will throw an ArrayIndexOutOfBounds error. It shouldn't restart your server.

    Can you post your server.log, or at least the portion relating to my plugin's error?
     
  18. Offline

    Lorden

  19. Offline

    krinsdeath

    @Lorden - I did 0 (zero) testing, but I just added a flag _global and checked it if no block is matched. It's in 0.4.2, which is up now. It contains only this little hotfix, so it's not important for anyone else to download (unless you want to specify global cooldowns on blocks!)

    Code:
    groups:
      users:
        commands:
        blocks:
          _global: [2, 0]
          dirt: [10, 0]
    
    If there's any problem, be sure to let me know.

    note: You shouldn't have to worry about deleting your config to get the new one, if you're comfortable editing YAML files, just add the key to your blocks node!

    edit: not having this flag in your config files should make no difference at all
     
  20. Offline

    dralletje

    can you also add resets?
    I mean that a toggleable command is execute x seconds after you execute the first command.
    so I mean: /fly -> 10 seconds -> /land
     
  21. Offline

    krinsdeath

    That would require an insane amount of complex linking and probably an impossible amount of configuring. The complexity of the project is already growing beyond my capabilities as a Java programmer; I've only just begun learning the language.

    I may implement that at some later date (I'm maintaining this code as best I can), but I'm currently redesigning this project from the ground up with a much more detailed and object-oriented approach.

    TL;DR: No, I can't. But I may eventually.
     
  22. Offline

    Jobsti

    @krinsdeath

    Hi, testing the new version.

    Configs:
    Code:
        Admins:
            damage: none
            move_cancel: false
            cooldowns: local
            chat_prefix: ''
            commands:
                spawn: [30, 6]
            blocks:
    
        warming:
            _generics:
                start: "&6<command> &7wird in &6<cd> &7Sekunden ausgeführt"
                end: "&6<command> &7ausgeführt"
                cancel: "&6<command> &7warmup cancelled"
                recurring: "&6<command> &7in &6<cd> &7Sekunden"
            start:
                # commands here
                #spawn:
                   # _self: "&7test"
                   # _others: ""
    
        cooling:
            _generics:
                start: "&6<command> &7kann erst in &6<cd> &7Sekunden wieder genutzt werden"
                end: "&6<command> &7kann jetzt wieder genutzt werden"
                cancel: "&6<command> &7kann wieder genutzt werden"
                recurring: "&6<command> &7kann erst in &6<cd> &7Sekunden wieder genutzt werden"
    
    
    Now, If i type /spawn I see the Message "spawn wird in 6 Sekunden ausgeführt" -> Correct
    6 seconds later "ausgeführt" -> <command> doesn't work for "end:" in config (for "cooldowns: global" it works correct)
    But noting happens, -> I have to type /spawn again to be teleportet!

    Console Error:
    Exception in thread "Timer -6".....

    Now I type /spawn again (before the 30 seconds are over), it shows me:
    "spawn kann erst in 0.0 Sekunden wieder genutzt werden" newline: "spawn wird in 6 Sekunden ausgeführt"
    -> The cooldown time isn't correct, and it shouldn't show me the 2nd line with the startmessage.

    After the 30 seconds, everytime I type /spawn "spawn wird in 6 Sekunden ausgeführt", -> but nothing happens.....

    The next thing:
    If I alter
    Code:
     #spawn:
                   # _self: "&7test"
    to

    Code:
     spawn:
                   _self: "&7test"
    Chat Shows "{Jobsti= test"


    Tip:
    Look at the MyHome Plugin, the Warmup und Cooldowns works perfectly ;)
     
  23. Offline

    krinsdeath

    The problem is that I'm trying to intercept ~every~ plugin's command before it gets executed, and apply warmups and cooldowns to them according to a dynamically generated config file based on user settings.

    The other problem I'm having is that, with local cooldowns, there is a massive amount of recursion in order to cool each command individually (I have to check each command in the player's entire list for cooldowns and warmups, manage them, and then move to the next player)

    The code logic looks like this:

    Code:
    if (player has global cooldown flag) {
      if (player is cooling) {
        // player is cooling down, and has global set to true, so we cancel the event
      } else {
        if (player is warming) {
          // player is warming up, so we check if his warm up is global
          if (player has global warmup flag) {
            // player has global warmups set to true, override or cancel the old command
            // replace old command with new one
          } else {
            // player has local warm ups, so override or cancel old command (based on user prefs)
          }
        } else {
          // player isn't warming up, so we check if the command that got us to this point is in his command mappings
          if (player has command mapped) {
            // player has the command mapped, so we check what the cooldown and warmup are
            // and schedule the command
          }
        }
      }
    }
    
    That nested block of ugliness is JUST if the player has global cooldowns set to true! Imagine if he has local cooldowns? The logic gets ridiculous.

    edit: @Jobsti - check out the project source at https://github.com/krinsdeath/cooldowns- and see for yourself. Maybe you'll be able to help? My brain is tired from the recursion. :(
     
  24. Offline

    IEclipseII

    I'm having trouble configuring it :p Could you help please?
     
  25. Offline

    GFlow

    Same.. It used to work, then I updated and none of my "Users" can use /spawn.
     
  26. Offline

    krinsdeath

    The plugin got too complicated for my taste. I'm currently redesigning it, and the next iteration will natively support the internal "Super Permissions" that Bukkit has by default, and will attempt to make quick use of SpaceManiac's PermissionsBukkit.

    I'll be slowly fazing out Permissions 2.x and 3.x support, in favor of this new system.

    Furthermore, I will not be programming in local warmups, only local cooldowns. I recommend rolling your version back to one of the earlier ones while I work on this. Very sorry for the inconvenience.
     
    GFlow likes this.
  27. Offline

    krinsdeath

    Alright! Version 0.5.0 is now released. I've done a lot of local testing and unit testing, on top of redesigning the project from the ground up. I couldn't encounter any bugs during my local testing, but that just means it's relatively stable with one guy throwing commands at it. The new configurations and localizations are considerably less complex, and offer (what I think is) a lot more customization without being so intimidating.

    Hopefully this release addresses a lot of the issues the plugin had, but it also removes a few features (move canceling commands, for example) that I felt added complexity without a lot of benefit. If I can find a way to safely add features without breaking the core functionality, I definitely will, but as it is, this should suffice for what I feel the plugin needs to do.

    As always, I'll be happy to offer support for any problems that do crop up (I imagine a few will), but please be thorough in your reports of what was happening, how it happened, and preferably any stack traces and server logs of the event.

    Thanks everyone, and have fun!
     
  28. Any way to set different cooldowns for different commands?
     
  29. Offline

    krinsdeath

    I'm assuming you mean commands that cooldown separately, in which case, no, there is not. The logic for performing operations like that is astounding, and iterating through massive lists of commands on large servers could prove problematic (beyond simple Concurrency issues, there's also the fact that a command list of 10 commands on a 50 person server is 500 loops per second, not counting other plugins)

    As for the cooldowns, the commands cause a global cooldown for all commands mapped to that group for that user, but each cooldown is unique; a cooldown for "home" set to "4" will cool all commands for 4 seconds, while a cooldown for "warp" set to "12" will cool all commands for 12 seconds.

    I'm getting ideas slowly of how to implement this successfully, but as it is it's simply not feasible.

    If this doesn't answer your question, could you provide a simple use case so I can tell you if it's possible?
     
  30. Offline

    Magesblood

    Alright been trying multiple things but I can't seem to get "f home" and "/f home" Warmups working.
    Code:
    plugin:
      worlds:
        - 'PvP'
      prefix: '[<fullname>] '
      default_locale: 'en_US'
      available_locales: [en_US]
      colors: false
      block_limiter: false
    groups:
      Killer:
        prefix: '[default] '
        commands:
          warmup:
            f home: 5
            /f home: 5
          cooldown:
        blocks:
      Helper:
        prefix: '[default] '
        commands:
          warmup:
            f home: 5
            /f home: 5
    
          cooldown:
        blocks:
      Mod:
        prefix: '[default] '
        commands:
          warmup:
            f home: 5
            /f home: 5
    
          cooldown:
        blocks:
      Admin:
        prefix: '[default] '
        commands:
          warmup:
            f home: 5
          cooldown:
        blocks:
      Donator:
        prefix: '[default] '
        commands:
          warmup:
            f home: 5
            /f home: 5
    
          cooldown:
        blocks:
     
  31. Offline

    krinsdeath

    Sorry, the syntax is a bit confusing.
    Code:
    groups:
      default:
        prefix: 'etc'
        commands:
          warmup:
            f:
              home: 5
          cooldown:
            f:
              home: 5
        blocks:
    
    I apologize for the confusion. :D
     

Share This Page