Set PAPI

Discussion in 'Spigot Plugin Development' started by mrkino99, Nov 28, 2019.

  1. Hi, How would you set placeholder api in a List<String> taken from the config and with the parameter ChatColor.translatealternatecolorcodes?
    Because i have tryied a lot of times How to do it, and it never changes the variable, for example %player_name%

    I need to do it in scoreboards and in messages
     
  2. Strahan

    Benefactor

    I've never used the placeholder API, but instead of applying it against a List you likely have to apply it against the elements in the list. Like whenever you go to use the list data, when you extract an element you apply the placeholders.
     
  3. Could you provide the code that's related to this portion of your issue?
     
  4. Yes of course, please wait a moment....
     
  5. Do you mean looping the list? I mean with a for(String s : list) {}
     
  6. ok, i have this code:
    Code (Java):
    public void alEntrar(PlayerJoinEvent event) {
            Player jugador = event.getPlayer();
            FileConfiguration config = plugin.getConfig();
            FileConfiguration messages = plugin.getMessages();
            String prefix = messages.getString("Messages.prefix");
            if(jugador.hasPermission("tplobby.joinmessage")){
                for(Player p : plugin.getServer().getOnlinePlayers()) {
                    PlaceholderAPI.setPlaceholders(p, messages.getString("Messages.join-message"));
                    p.sendMessage(ChatColor.translateAlternateColorCodes('&', messages.getString("Messages.join-message")));
                }
            }
    }
    and my config yml is
    Code (YAML):
    Config:
     #PAPI is available in this path
      join-message
    : "&aPlayer %luckperms_prefix% &5&l%player_name% &ahas joined the lobby"
    and PAPI are not getting replaced...