Removing & codes from a message

Discussion in 'Plugin Development' started by ThrustLP, May 21, 2016.

Thread Status:
Not open for further replies.
  1. Offline


    Hello guys! Simple problem: I check if a player has the permission to write in colere, and if he has not I want to remove the colorcode from his message. What I have so far:

    msg = msg.replace("&", "");
    But I do not want to remove the &, I want to remove the & and the char after it. Is there a good way to do that?

    Thank you!
  2. Offline


    msg = ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&', msg));

    This turns your & color codes into minecraft's ยง color codes, and then uses bukkit's utility method to remove those minecraft color codes.
  3. Offline


    Or you could just make a modified version of the stripColor method to do it without needing to convert it to colors first.
Thread Status:
Not open for further replies.

Share This Page