Make a player able to gain more playtime?

Discussion in 'Plugin Development' started by Trevor1134, Jul 4, 2013.

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

    Trevor1134

    I have this code:
    http://pastebin.com/uZsaWaXM
    So when a player joins, they get added to a list which lets them play for 500 minutes. I want to know how I can make it so :
    If they kill a mob, they get more time.
    Thanks!
    (If you have a better way, let me know)
    KillEvent code: (Current)
    http://pastebin.com/tqMv2iNd
     
  2. Offline

    SnowGears

    Ahhh what are you doing! Dont put actual player instances in maps or lists. Instead store their names.

    But to answer your question, what I would do is make a HashMap instead of an Arraylist. That way you can store the times of players with the actual players themselves.

    Example:
    HashMap<String, Integer> playerTimes = new HashMap<String, Integer>();

    Then you can have a setter method and when it gets to zero kick the player. Or you can even try out MetaData for this. Not sure but from what it sounds like you can use it for players as well.
     
  3. Offline

    Trevor1134

    Tooner101 Please give me an example? I am kind of having an issue understanding.

    T3h Cr33p3r cool! I will pm you?

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

    pkt

    :confused: What happened to creepers code... I was gonna say that you don't need to remove a key from a hashmap, then put it back. .put() will replace the key if its already in the HashMap
     
Thread Status:
Not open for further replies.

Share This Page