Solved String replace

Discussion in 'Plugin Development' started by Josh014, Dec 24, 2014.

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

    Josh014

    Hello!

    I'm trying to get %PLAYERNAME% out of a string and replace it for a players name. I used .replace("%PLAYERNAME%", player.getName()); but that didn't work. I probably messed something up.

    My code:
    Code:
                            String sJoin = ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("Messages.JoinMSG"));
                            sJoin.replace("%PLAYERNAME%", player.getName());
                            player.sendMessage(sJoin);
    Thanks,
     
  2. Offline

    teej107

    @Josh014 replace() method returns a new String with the new value. It doesn't modify the original String at all.
     
  3. Offline

    Josh014

    @teej107
    Ahh alright. Is there a way to do so?
     
  4. Offline

    Skionz

    @Josh014 Set 'sJoin' to the new String.
     
  5. Offline

    Josh014

    Nvm fixed it
     
Thread Status:
Not open for further replies.

Share This Page