Replace StringLists

Discussion in 'Spigot Plugin Development' started by zozidalom, Jun 9, 2016.

  1. So in my config.yml I have a string list and I want to replace %player% to a player in all if Strings in the list. How could this be done?
  2. replace("<object>", <newObject>);
  3. I only have replaceAll there is no replace...

    Attached Files:

  4. MiniDigger


    you need to call the replace on each string, not the list<string>
  5. Well. But how to get all the strings? So my code is the following:
  6. MiniDigger


    you already get all your strings in the for loop...
    just call replace on your string cmd after the loop is done.
  7. He needs to learn Java. He can't even iterate over a string list...

    Screw it, I'll spoon feed you:

    for (String s : <getStringListHere>) {
    s.replace("<Object>", <newObject>);
  8. MiniDigger


    your spoonfeed does nothing. you don't catch the result of the replace method. string are imutable...
    annnnd op already has a loop in place where he could call the replace method.