1.16.5 ChatColor.translateAlternateColorCodes not working?

Discussion in 'Spigot Plugin Development' started by Sanfeanso, Sep 15, 2020.

  1. Hey! I'm making a custom death messages plugin (for an smp) with a customizable yml file. I used the method or whatever its called in the title to translate the color codes, yet something weird happens. If I put "&c&ldude ur so trash TAKE THE L %" it will say "ur so trash TAKE THE L %" instead and there are no colors. Anyone know why?

    Here's my code:
    event.setDeathMessage(ChatColor.translateAlternateColorCodes('&', deathMessages.get(rand.nextInt(5)).replaceAll("%", event.getEntity().getName())));
    #1 Sanfeanso, Sep 15, 2020
    Last edited: Sep 15, 2020
  2. Invvk

    Invvk Previously iTzGhostx

    can you show us the full code including 'deathMessages'
  3. Invvk

    Invvk Previously iTzGhostx

    you didn't add the color code in the messages in the default config
  4. Yes, but I changed it manually.
  5. Can you show the config file? And why you are not using yaml.getStringList("messages");? It will be more efficient. And you can load the config at onEnable() method in the main class instead of load the config file every time a player dies.
    #6 Anonymous_Dr, Sep 15, 2020
    Last edited: Sep 15, 2020
  6. Try to do a debug to check if messages are good-loaded.