[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

    GFlow

    Thank you! If you can do cooldowns, can you also do warm up times? Having both would help greatly.
     
  3. Offline

    Fr0zenfr0g

    warm up times? what do you mean?
    great plugin!
     
  4. Offline

    krinsdeath

    Yeah, I'm not 100% sure what you mean by warm up times.

    It wouldn't be ~too~ ridiculous if certain things (for example, taking damage?) caused a global cooldown (ala WoW or other MMOs), but it gets complicated if you want cast times (example: type /home and 10 seconds later it "casts it" and you teleport home)

    So I guess it becomes "which one do you want"?
     
  5. Offline

    GFlow

    yeah warm up times, like using /home and waiting 10 seconds for it to work.
     
  6. Offline

    Alesana

    This is what i was looking for ... thank you! I'll try it as soon as I can! :p
     
  7. Offline

    krinsdeath

    New version (0.2.0). Added block placement cooldowns, idea from this thread. Thanks to @Lorden for the idea!
     
  8. Offline

    dohwee

    Krinsdeath,

    it'll be great if you can make like a World OF Warcraftt type.

    10 Seconds cast.. IF you get hit or damaged by monster it will cancel the /Spawn /Home.
    its really an essential plugin for Pvp servers.
     
  9. Offline

    Jobsti

    Hey nice plugin, works with #953 for me.

    If commands are blocked, the message is: "You cannot place blocks yet".

    Request:
    - Customizable messages (+color) for block- and command-cooldowns!
    - Command/block - Warmups.
     
  10. Offline

    krinsdeath

    Alrighty. Since it's been requested a couple of times now (warm ups/cast times), I'll start working on that.

    @Jobsti - Thanks for letting me know about the issue with the message being wonky! I'll set up a localization file so that if it's needed, all of the messages reported by the plugin can be customized to any language. I'll put the new version up sometime today (hopefully).

    I'd like some input on how you want to configure the warm up times for the various commands. :x

    Right now we have fields like:
    Code:
    groups:
      users:
        commands:
          home: 30
        blocks:
          cobblestone: 2
    
    I could turn the fields into a list, ala [30, 5], where the first number is the cooldown and the second is the warm up/cast time.

    Ideas?
     
  11. Offline

    riuthamus

    This is a great plugin. Seriously... great idea and works really well if you wanted to limit the players from doing certain things.
     
  12. Offline

    krinsdeath

    After much tooth-gritting and many dumb bugs, 0.2.2! Fixes many things, improves localization (a few parseable variables), and adds Warmup times!

    Haven't yet included the ability to "reset" the warmup when the player takes damage, and it ignores command input after you set up a command in the scheduler (so once you type /home, it will halt all commands while it processes and eventually execute no matter what)

    0.2.3 should have player damage events and cancellable commands. Stay tuned? :eek:
     
  13. Offline

    FoxXF1R3

    Just checking on a possible issue, the plugin works great except it doesn't seem to work with multi part commands such as /f * . I'm wondering if I can get it to warmup only certain /f commands. As in I would like to have users be able to /f help without warmup, yet still warmup /f home. Is there a workaround?
     
  14. Offline

    GFlow

    Great work so far. [cake]
     
  15. Offline

    krinsdeath

    Ehh, I didn't really think of that. It wouldn't be too hard to implement, but it might make the configuration files even more complicated than they are now. I'm not sure if that's desirable, but I can see how it might be inconvenient if you have commands rolled together like that.

    I'll take a look at it, and if it isn't too ridiculous, I'll implement that next!

    example ->
    Code:
    groups:
      users:
        commands:
          f:
            home: 10
            help: 0
          time: 5
      admins:
        # etc?
    
    Note: I'm restructuring the plugin since it has grown massively in scope. I'll be changing the name to just "Cooldowns," and completely starting from scratch just to make things more tidy. My own code was almost too obfuscated to navigate, so it might be a while before a meaningful release comes about.
     
  16. Offline

    LlmDl

    All this needs is warmup support for /town spawn and I'll begin using it.
     
  17. Offline

    krinsdeath

    Made some progress on cooldowns/warmups, but it's not finished yet (obviously). Here's some screens of what it will ~sort of~ look like. The number of messages you receive is configurable (via "/cooldowns verbosity true|false")

    screenshots (open)

    [​IMG]

    [​IMG]
     
  18. Offline

    Jobsti

    New version works great!

    Request:
    - %cooldown% would be nice
    - And please remove the '' and the /, we could set it by self, if we want.

    So we could set: You can only warp to Spawn after 90 seconds. 34 seconds left.

    Idea:
    - for the locale file, different messages for each command/block.
    - message if cooldowned.

    Code:
    cooling:
    spawn: message for /spawn
    home: message for /home
    time: message for /time
    command: mastermessage for all other cooldown /commands
    
    cooldowned:
    time: message for /time
    command: mastermessage for all other cooldown /commands
    
    cobblestone:
    id=1: Message for Cleanstone
    id=2: Message for Grass
    block:  mastermessage for all other cooldown blocks  
     
  19. Offline

    krinsdeath

    I would love to do that, Jobsti, but it gets insanely complex when you want to do non-static amounts of sub-keys in the node trees. Java doesn't seem to be very good at dynamic objects and file manipulation :( (at least compared with what I'm used to)

    Hopefully this version update (0.3.0a) will alleviate some of the issues you have. Just started with Java a few days ago, so some of these syntax rules are confusing me!
     
  20. Offline

    Piedo_bear

    Tested this.

    0.2.2 works fine, with the permission cmdcooldown.users
    0.3 doesn't work at all, no cooldowns. Tried using default config, using low-high cooldown/warmup values. Permissions true/false but it still wouldn't work.

    Perhaps I am doing something wrong
     
  21. Offline

    krinsdeath

    @Piedo_bear - Can you give me your server.log (or just post a screenshot of when it's enabled?), any relevant errors, and possibly a screenshot in-game of when you use a command? The default values are kind of weird, and version 0.3.0 changes the permissions flag to 'cooldowns.users' or 'cooldowns.admins' because of the rename. I'm also building it against the latest CB (953) and Bukkit (956), as well as Permissions 3.1.6.

    With local testing, I get no errors and everything works fine (permissions true/false, default values, isOp()/normal user)

    :x

    edit: Just realized that I erased the comments in the config regarding permissions nodes, and never updated them in my main post. This is probably your problem. Fixing the post (and config.yml) now. The new jar is available at the same link (with same version number). I added some code and additional checks and redundancies, so it should be fixed. :x
     
  22. Offline

    Jobsti

    Yeah it works! (Groupmanager 2.4, CB#953)

    But:
    cooling:
    stopped: "<command>" Not testet
    current: "<command>" Doesn't work, shows nothing.

    And <command> gives a / in front of the command.
    Deactivating the slash would be nice. It should be show "spawn" not "/spawn" ;)

    Edit:
    -> Oh nooo.... cooldown for ALL commands. wtf?! (I can use all commands, but if I type /spawn) ALL commands have a Cooldown)
    -> If I type /spawn, I get the Warpup, in Warmup i type /spawn again, it execute the command /teleports me to Spawn.

    Config:
    Code:
        commands:
    #      time:
    #        set: [10, 5]
    #        add: [5, 2]
    #      give:
    #        CDself: [60, 2]
    #        CDothers: [300, 10]
          spawn: [20, 6]
     
  23. Offline

    krinsdeath

    I'm not sure what you mean by your edit? As for the <command> parse, "cooling" is just a status and has no command associated with it (since the cooldown is global and affects all commands).

    I suppose it would be possible to create linked lists of commands that affect each others' cooldowns (such as linking together all "teleport" type commands, or all "item" type commands

    I don't see anything wrong with your config. What is the unwanted behavior?
     
  24. Offline

    Jobsti

    Ah the cooldown is global for all commands (also the ones, which are not in the config), if I type a command from the config? Shit ;-)

    - I want a warmup and a Cooldown only for the commands which I added to the config.
    In my cfg is only "spawn"
    If I type /spawn, only /spawn should have a cooldown, not all the other Server- and Plugin-commands.

    - If a command has 6 seconds Warmup, and during the Warmup I type the command again, it should show a message and don't execute the command, before the 6 seconds are over.
    Now: It executes the command instantly, and a 2nd time after the 6 seconds!

    - Bug: Commands from MCDocs works, but shows also the cooldown message, during the cooldown. (commands are not in the config! See my first point)

    Edited....

    Edit:
    If I set " spawn: [0, 6] "and type /spawn the " cooling: stopped:" Message will be shown.
    0 should disable the message.

    An empty Message, shows a empty line in the chat. ;-)
     
  25. Offline

    krinsdeath

    I'll work on creating individual cooldowns for every command, but it might be a while. I'm not terribly familiar with Java, so figuring out how to iterate through lists of commands with differing cooldowns and (I assume) warmups, and store them efficiently (especially on a large scale) will be difficult (at best).

    As for what you suggested, the way it works right now is that it overwrites the current command warming up with the new one (effectively allowing you to "cancel" a command with a dummy command), or at least that's how it should work. If you type the same command again, it should just restart the warmup timer to the default.

    As for commands cooling down only if they're in the config, I just added that and it will be in the next release (which should be either late tonight or tomorrow, but I can't guarantee anything).

    edit: regarding MCDocs, I'll have to find the source and see how it hooks the player command events and determine if there's some kind of conflict. What exactly is it doing when you execute commands from MCDocs?
     
  26. Offline

    Jobsti

    MCDocs shows only texts from txt documents.
     
  27. Offline

    krinsdeath

    Writing to maps of keys containing maps of keys is very obfuscated and awful. :(

    Currently working on implementing localization for individual commands and blocks, and separated cooldowns and warmups for individual commands. Current release is going to have to suffice until I can properly code this out. Blocks will not have separated cooldowns unless it is absolutely necessary

    This will take a couple of days, I think. My brain hurts with all of the recursion.
     
  28. Offline

    Monkz

    Request: Add a configurable option of true or false to force people to stand still on warmups without being hurt or else it would interrupt.

    :D
     
  29. Offline

    krinsdeath

    Alright. I'm still working on the PLAYER_MOVE event to cancel warm ups while moving, but 0.4.0 adds a significant amount of content. Hopefully it works out (I have limited testing capabilities locally), but if it doesn't then bug reports would be excellent.

    note: 0.4.0a is ready! The main post contains the new config.yml and en_US.yml layouts. Old versions ~will not~ work with this, because of the changes to how the engine parses the node tree. Some examples are given with the basic server wrapper commands (give, time, list).

    As always, feedback appreciated!
     
  30. Offline

    Likwidface

    the .4a update seems to be broken completely. It works and doesn't work with random installs and reboots, with no clear reason as to why. I love where this is going but wouldn't implement just yet..


    2011-07-09 18:09:12 [SEVERE] Could not pass event PLAYER_COMMAND_PREPROCESS to Cooldowns
    java.lang.NullPointerException
    at net.krinsoft.cooldowns.PlayerData.mapCommands(PlayerData.java:335)
    at net.krinsoft.cooldowns.PlayerData.<init>(PlayerData.java:55)
    at net.krinsoft.cooldowns.Settings.addNewUser(Settings.java:129)
    at net.krinsoft.cooldowns.PListener.onPlayerCommandPreprocess(PListener.java:15)
    at org.bukkit.plugin.java.JavaPluginLoader$5.execute(JavaPluginLoader.java:272)
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:58)
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:321)
    at net.minecraft.server.NetServerHandler.handleCommand(NetServerHandler.java:704)
    at net.minecraft.server.NetServerHandler.chat(NetServerHandler.java:676)
    at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:669)
    at net.minecraft.server.Packet3Chat.a(Packet3Chat.java:33)
    at net.minecraft.server.NetworkManager.b(NetworkManager.java:226)
    at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:84)
    at net.minecraft.server.NetworkListenThread.a(SourceFile:105)
    at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:451)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:361)
    at net.minecraft.server.ThreadServerApplication.run(SourceFile:422)
    2011-07-09 18:09:15 [SEVERE] Could not pass event PLAYER_COMMAND_PREPROCESS to Cooldowns
    java.lang.NullPointerException
     

Share This Page