Translating Color Issue?

Discussion in 'BungeeCord Plugin Development' started by Mhalllz, Mar 14, 2019.

  1. So I made a bungee plugin that manages chat and has specific channels ect; when people send a message in color that is more then one line it goes white on the anylines > 1
    WHAT.PNG
    does anyone know how to fix this?

    This is the method I use to translate colors:
    Code (Java):
        public static String translateColor(String Message) {
            return ChatColor.translateAlternateColorCodes('&', Message);
        }
     
  2. You might want to follow the Java naming conventions. Are you importing the correct ChatColor class?
     
  3. Yes, I'm using "import net.md_5.bungee.api.ChatColor"
     
  4. Does anyone know how to fix this issue :(
     
  5. That's unfortunately the way Minecraft does this.
    Use Chat components if you don't like this, I think that stops it.
    Get them using ComponentBuilder or TextComponent#fromLegacyText.
    Then send them like this:
    Code (Java):
    proxiedPlayer.sendMessage(new ComponentBuilder("Text").color(ChatColor.BLUE).otherstuff().build());
     
  6. To send a message instead of doing a new TextComponent (ex: player.sendMessage( new TextComponent( translateColor( message ) ) ); ) you use TextComponent#fromLegacyText (ex: player.sendMessage( TextComponent.fromLegacyText( translateColor( message ) ) ); )
    Also follow the java conventions.
     

Share This Page