Parsing Colors from a String.

Discussion in 'Plugin Development' started by JasonW, Dec 18, 2011.

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

    iPhysX

    If i had this inside a file.

    &4Hello world.

    How would i make this into,

    Code:java
    1. pl.sendMessage(ChatColor.??? + "Hello world.");
     
  2. this code was made by a guy on this forum named r3fuze

    pass the string into it and it replaces <color> with the right stuff c:



    Code:java
    1. public static String format(String string) {
    2. String s = string;
    3. for (ChatColor color : ChatColor.values()) {
    4. s = s.replaceAll("(?i)<" + color.name() + ">", "" + color);
    5. }
    6. return s;
    7. }
     
  3. Offline

    iPhysX

Thread Status:
Not open for further replies.

Share This Page