Solved Hashmaps?

Discussion in 'Plugin Development' started by lycopersicon, Feb 8, 2013.

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


    I'm working on a plugin for a mini-game server I'm developing. I'm pretty new at this stuff. Anyway, I have a hashmap of player, integer, and I want to write a command that will return to the sender their integer. The player is in the hashmap with an integer assigned to them. The command should return the integer of the player sending it. I've been toying with this for a while now and I can get it so that when the command is run they get a message with EVERYONE's integer. I would like it to be just theirs.

    Any help would be very much appreciated.
  2. Offline


    You could always do:
        // get(player) will return the integer associated with the player
    Also, don't have the player in the hashmap, have their name. So instead of:

    Map<Player, Integer> myMap = new HashMap<Player, Integer>();
    Map<String, Integer> myMap = new HashMap<String, Integer>();
    This way it avoids memory leaks.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 31, 2016
    lycopersicon likes this.
  3. Offline


    Thank you so much for your replies! It really helped me out. Also, you are 100% correct I should be using string rather than player. I just got sloppy with it and am too lazy to change it..... -.-

    I will though lol.

    Thanks again for your assistance, it is greatly appreciated!
Thread Status:
Not open for further replies.

Share This Page