Solved Config

Discussion in 'Plugin Development' started by __Sour, May 5, 2015.

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

    __Sour

    I was wondering how people made it so like in their plugins config file, if you put like %PLAYER% in a string, it would replace it with the players name.
     
  2. Offline

    567legodude

    @__Sour When you want to use the string, for example "Hello, %PLAYER%" you would replace the variable with the players name.
    Code:
    String base = "Hello, %PLAYER%"; //The base string
    base = base.replaceAll(Pattern.quote("%PLAYER%"), playername);
    
    //playername is the player's name obviously
    //%PLAYER% has now been replaced with whatever you put in for playername.
     
  3. Offline

    VG.Developments

    p.sendMessage(ChatColor.TranslateAlt....('&', getConfig().getString("path").replace("%player%", p.getName()));
    This allows color codes too. I think this is what your asking?

    - typed on phone.
     
  4. Offline

    __Sour

  5. Offline

    567legodude

    @__Sour You should also consider what @VG.Developments said, if you want to be able to use color codes in your message then add this:
    Code:
    String base = "Hello, %PLAYER%";
    base = ChatColor.translateAlternateColorCodes('&', base.replaceAll(Pattern.quote("%PLAYER%"), playername));
    
    //For using color codes.
     
Thread Status:
Not open for further replies.

Share This Page