Solved Config Variables

Discussion in 'Plugin Development' started by XSilverSlayerX, Jul 5, 2015.

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

    XSilverSlayerX

    Hello, i need help trying to add variables so when it sees {<player>} in my config it will know to replace it with the current player it is sending the message to. Here is what i have:

    String line1 = ChatColor.translateAlternateColorCodes('&', getConfig().getString("line1"));

    String getplayername = ChatColor.translateAlternateColorCodes('&', getConfig().getString("line1", ChatColor.RED + "" + ChatColor.BOLD + "" + "").replace("{<player>}", p.getDisplayName() + ""));

    p.sendMessage(this.line1);

    in config:

    line1: "&currently online: {<player>} "

    -----------------------------------------------------------------------------------------------------------------------
    Results: currently online: {<player>}
    So my problem is how do i make it so when i get send the line1 string that it replaces the variable {<player>} to XSilverSlayerX or what ever player it is being sent to? Thanks!

    Nevermind solved my own problem. Correct code would be:

    String line1 = ChatColor.translateAlternateColorCodes('&', getConfig().getString("line1").replace("{<player>}", p.getDisplayName() + ""));

    p.sendMessage(this.line1);

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 12, 2016
Thread Status:
Not open for further replies.

Share This Page