Simple listing of players won't list any players

Discussion in 'Plugin Development' started by LeePMC, Mar 11, 2015.

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



    i have recently been working on a staff list plugin/online players list plugin and well I'm stumped... i have tried the plugin on my test server and all it gives when i type


    is "Online Staff: -2"

    i know why the -2 is in there and that is because i was trying to remove the

    ", "

    at the end but i don't think putting -2 at the end will help get rid of it, all the source code to this plugin is at

    i would really love if someone could help me figure out why its not working and help me with removing the

    ", "

    after the last name listed, if you need any further information, i would be happy to put it in, also there are no errors like console errors if anyone asks, because the plugin works just isn't doing what i want it to do :/ please help xD
  2. String s = sb.toString();
    would be something like this: "player1, player2, player3, " so ", " (2 chars) at the end will need to be removed:
    s = s.substring(0, s.length -2);

    And its complete nonsense to add players to the list in onDisable because the list (and all other variables in your plugin) will be reset after onDisable
  3. The methods found here convert a list to a string, with the defined separator. You can see the methods being tested here.
    Last edited: Mar 11, 2015
  4. Offline


    @FisheyLP Thanks for the help, i dont know what i was thinking when i put the useless methods int he onDisable xD, but thanks for the string builder help, i will try it out as soon as i get home, @ZonalYewHD i now how to make a list into a string, i was doing it in my class already, and the method you gave me looks a tad bit more complicated than it needs to be, but thanks for helping :D
  5. @LeePMC I just added support for 'and' before the last entry. It's part of my OCD :p Also, the main reason nothing was being added is because you were trying to add strings from the arguments after you made sure that there were no arguments. I submitted a pull request so you can see how to fix it. Also, your method wasn't including the first element in the list, therefore the first name would be skipped. I fixed this by adding the first entry of the list to the StringBuilder's constructor. Again, check my PR to see how to fix it.
    Last edited: Mar 12, 2015
  6. ...Wrong thread, sorry...
  7. Offline


    O my, I am really beging to think I should read my code 3 times over, I have removing a the stuff in onDisable already, and thanks for the help with that I would have never figured that out... @ZonalYewHD
Thread Status:
Not open for further replies.

Share This Page