Solved How can I get the text of a yaml file and get it on my .java file

Discussion in 'Spigot Plugin Development' started by BremiWorld, Aug 4, 2018.

  1. I know it's a stupid question but I don't know how to get the text from format
    Code (Text):
    Config:
      chat-format:
        enabled: true
        format: "&c%player^ &8>>"
    to my plugin.java file. could someone tell me how to do it please?
     
  2. You mean like copy the entire config into your Java file or just certain values?

    Edit: Nvm, didn't read it properly. Do Config.chat-format.format
     
  3. I want to get the things on format, like the text between "", where it says "&c%player^ &8>>"
     
  4.  
  5. I mean, what else do I have to put? maybe something of getText or something like that? So what do I have to put like if i want to do a player.sendMessage(what does it have to say inside here)
     
  6. Doesn't matter, I already found out how:
    Code (Text):
    List<String> message = messages.getStringList("Config.chat-format.format");
                    for(int i=0;i<message.size();i++) {
                        String text = message.get(i);
                        player.sendMessage(ChatColor.translateAlternateColorCodes('&', text.replaceAll("%player%", player.getName())));
                    }
    But thank you so much anyways
     
  7. Optic_Fusion1

    Resource Staff

    actually, just do

    String format messages.getString("Config.chat-format.format");
    assuming it only has one format
     
    • Like Like x 1
  8. Oh, thanksss, because it still didn't work, and thx to you it does. :)