Solved Hologram command via Config.yml

Discussion in 'Spigot Plugin Development' started by ElbestHD, Jan 24, 2019.

  1. Hello people from spigot, I'm doing a command that shows a hologram of statistics of the players and that those lines can be edited via config.yml but it does not work out very well. SORRY MY INGLESH
    Code (Text):
    f (Main.getPlugin().getConfig().getBoolean("Hologram.HolographicDisplays")) {
                         Hologram hologram = HologramsAPI.createHologram(Main.getPlugin(), p.getLocation());
                         List<String> config = Main.getPlugin().getConfig().getStringList("Hologram.lines");
                         List<String> lines = new ArrayList<String>();
                          for(String l : config) {
                              lines.add(l.replace("<name>", String.valueOf(p.getName()))
                                        .replace("<kills>", String.valueOf(SQL.getKills(p.getUniqueId().toString())))
                                        .replace("<deaths>", String.valueOf(SQL.getDeaths(p.getUniqueId().toString())))
                                        .replace("<rank>", String.valueOf(SQL.getRank(p.getUniqueId().toString())))
                                        .replace("<elo>", String.valueOf(SQL.getELO(p.getUniqueId().toString())))
                                        .replace("&", "§"));
                          return true;
    Code (Text):
       HolographicDisplays: true
       - " 0,  Tus Estadísticas"
       - "1,  "
       - "2, Jugador: <name>"
       - "3, Rango: <rank>"
       - "4, Tu ELO: <elo>"
       - "5, Total Asesinatos: <kills>"
       - "6, Total Muertes: <deaths>"
    #1 ElbestHD, Jan 24, 2019
    Last edited: Jan 26, 2019
  2. By using hologram.appendTextLine(lines.toString()); you are converting all the lines to one string.

    You need to call hologram.appendTextLine(); with each line.
    • Agree Agree x 1
  3. I get an error if I do that
  4. List<String>#toString will return the elements of the collection in a form of [element, element2, ...., element999]. You are basically getting a list and setting it to the next line of the hologram. What you want to do is move the Hologram#appendTextLine in that for loop and use it on l. Or you could do list.forEach(line-> hologram.appendTextLine(line));
  5. thank you very much bro