Error trying to make placeholders

Discussion in 'Spigot Plugin Development' started by xDec0de_, Jul 24, 2018.

  1. Ok, so i want to make a placeholder on my config.yml that transforms %kills% to the number of kills of the player but i get this error: The method replaceAll(String, String) in the type String is not applicable for the arguments (String, int)

    Code (Text):
    for (String StatisticsMSG : getConfig().getStringList("Statistics.Message")) {
        StatisticsMSG = StatisticsMSG.replaceAll("%kills%", p.getStatistic(Statistic.PLAYER_KILLS));
  2. It tells you in the error...
    Learn some basic java and some common sense first.

    Hint: int. (string, int) is not (string, string). String. Value(Staticistic.PLAYER_KILLS);
  3. Code (Text):
    convert this int to a string.
  4. As @FatalPacket and @AgainstTheNight said, you have to convert your int object to a string because this is what the function requires you to provide her.
  5. If you aren't using regex matching, then stick to String::replace
  6. You can always use the PlaceHolderAPI if you want an easyer way