Solved ChatEvent Message Replacement

Discussion in 'Plugin Development' started by elian1203, Nov 30, 2015.

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

    elian1203

    I'm trying to make a simple plugin where if you have the permission, you can use chat color with the '&' symbol. No errors, just doesn't work.
    Example code (Just copied for different colors):
    Code:
            String m = e.getMessage();
    
            if(m.contains("&7"))
                if(p.hasPermission("colormychat.gray"))
                    m.replace("&6", "§7");
            e.setMessage(m);
     
  2. Offline

    mcdorli

    replace returns a new string, do m = m.replace("&6", "&7")
     
  3. Offline

    Zombie_Striker

    @elian1203
    This should not work. As @mcdorli said, you have to have m = at the beginning of the statement, because it returns a string; Its not a void.

    But also, you switched the Strings. The parameter on the left is the thing you want to replace. The one on the right is the String you want to replace it with.
     
  4. Offline

    elian1203

    Thank you it works well.
     
Thread Status:
Not open for further replies.

Share This Page