"Mana"

Discussion in 'Plugin Development' started by Eballer48, Oct 27, 2012.

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

    Eballer48

    So I have a RPG themed plugin and some classes use mana, obviously in most class based system your mana will regenerate over time so I was wondering what would be the best way of doing this?
    Every player that uses "mana" is kept in a Hashmap<String, Integer> so would it be best to run a constant timer and idk every 5 seconds get all the player's names in the Hashmap and check their Integer if it's < 100 then add some? Except running a constant timer could use a lot of resources right? Whats the best way of doing this. This method i'd also have to check to see if the player's online so they can't gain mana when offline.

    Tldr; Best method to make players regenerate mana?
     
  2. Offline

    CorrieKay

    use an async task. Something as small as this shouldnt hurt your performance c:
     
  3. Offline

    Sagacious_Zed Bukkit Docs

    Thats a bad idea with a standard hash map as it won't be thread-safe.
     
  4. Offline

    Eballer48

    So then what would you suggest?
     
  5. Offline

    CorrieKay

    Concurrency always bites me in the ass. Sorry :p
     
  6. Offline

    Sagacious_Zed Bukkit Docs

    Sync task if you are not going to bother with thread safety
     
  7. Offline

    Eballer48

Thread Status:
Not open for further replies.

Share This Page