Solved Iterate through values of a key in a multimap, and format them

Discussion in 'Plugin Development' started by TerraVale, Apr 26, 2013.

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

    TerraVale

    Hello. Recently I decided to create a plugin that allows the user to have their own buddy list where, of course, they can add and remove buddies.

    I'm now running into something that I don't know how to do, and would appreciate tips or suggestions from those who might have any ideas or know-how!

    My problem lies within the /buddy list command, which looks as such:
    http://codeshare.io/pmib2

    What is currently set up in this snippet of code allows the user to initiate the command /buddy list, which will then return whatever values they have assigned to themselves by adding players to their buddy list. As for the collection that is returned, I'd like to iterate through it and return two sets/tables/whatevers (I haven't worked with this stuff much at all) of strings where one will only contain online players, and one will only contain offline players.

    Does anyone have an idea of how to do this?

    Help is much appreciated. :D
     
  2. loop over the list with a enhanced for loop and add the contents you want to print to a stringbuilder, then convert that string builder to a string and send the player a message
     
    TerraVale likes this.
  3. Offline

    TerraVale

    I'm giving it a shot, but if I am to use an enhanced for loop my Collection needs to be an Array, and I don't know how to turn a collection into an array.

    Hmmm

    Scratch that, I'm making progress now!

    There we go, thanks for mentioning enhanced for loops. From there, I was able to figure out how to use a stringbuilder and how that functions, the setup is working great now!

    I very much thank you.
     
Thread Status:
Not open for further replies.

Share This Page