Cooldown period per player

Discussion in 'Plugin Development' started by Blackveil, Feb 22, 2014.

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

    Blackveil

    I have a system I made that updates item lore..etc

    Basically, you receive an item, you can "update" the information, the server checks the item and gathers all of the information needed, and will keep doing this if you trigger the event. How do you create a cooldown period so that a person can only trigger this event X amount of time?

    Process: Monster drops item, player picks up item, event is triggered. Server cleans item name text, then queries the database for item information/stats/data, name color/lore/etc is generated and set to the item. The server will do this every time the event is triggered, and it is triggered when the player switches items in their hand too. I want to create a timer specifically for the event where the player switches their item, except I want that timer to affect only that individual.
     
  2. Offline

    Tirelessly

    Blackveil Well here's a shit ton of posts about cooldowns
    And here's a shit ton of posts about having things be per-player
     
  3. Offline

    NathanWolf

    Just make sure you don't follow the millions of threads that claim you need to use a scheduler for cooldowns. You don't.

    Use a HashMap<String, Long> and store the last time the event happened for a particular player name. Next time the event happens, make sure your stored timestamp for that player is older than your cooldown.
     
  4. Offline

    Blackveil


    This is pretty much what I was going for. How would I go about creating the timestamp? I've used Java's built in Timestamp classes but they generate odd timestamps.
     
  5. Offline

    Tirelessly

    System.currentTimeMillis()
     
    NathanWolf likes this.
Thread Status:
Not open for further replies.

Share This Page