Getting a players name and a number then getting that number later

Discussion in 'Plugin Development' started by Whomp54, Dec 23, 2013.

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

    Whomp54

    So basically what I want to do is save a players "number" and get it later. Is this possible? If so, how would I do this? I am guessing with a HashMap but I honestly do not how to make a value stick to a username.


    Thanks for all that help.
     
  2. Offline

    Gater12

    Whomp54 You can have a key of the username and a value of an Integar.
     
  3. Offline

    xTigerRebornx

    HashMap<String, Int> playerNumbers = new HashMap<String, Int>();

    Wasn't done in an IDE, so might have an error, but you should get the general idea :p
     
  4. Offline

    Whomp54


    Yes, but how would I retrieve the value of the integer? If I would save an integer to a HashMap, how would I know that I will be returning the right integer that that player has?
     
  5. Offline

    Gater12

    Whomp54 You can use:
    hashMapNameHere.get(player.getName()); and it will get the value assigned to that username.
     
  6. Offline

    xTigerRebornx

  7. Offline

    Whomp54


    Thank you! I will try it out and get back to you on how it went :p
     
Thread Status:
Not open for further replies.

Share This Page