Removing & codes from a message

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

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

    ThrustLP

    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:

    Code:
    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

    blablubbabc

    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

    teej107

    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