In my plugin I get the size of a hashmap and pick a random number so say my hashmap is like this Code: (1) Notch, Good Guys (2) Jeb, Good Guys (3) Ect, Good Guys and the random number is 2, I want to get the row 2(Jeb) and set his thing to badguy. Thanks
I would think the Random object in Java would be good for this, although not with the HashMap, but rather a ArrayList with a series of player names in it. Assuming that there's a ArrayList<String> object called 'list' with the data above in it, we could do this: Code:java Random r = new Random();int num = r.nextInt(list.size());String badguy = list.get(num); Then the bad guy could be stored in a variable somewhere. Reason the HashMap wouldn't work is because a HashMap can't fetch a name by index as a list could. The Random object's nextInt(int) method fetches a int between 0 and the number specified, this also includes 0, so the first entry of the list won't be ignored.