Solved Replacing Words

Discussion in 'Plugin Development' started by ryryanator, Sep 1, 2014.

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

    ryryanator

    So i'm trying to make a simple plugin that replaces a word with a word. But I can't get it to work.
    Code:java
    1. public class ChatListener implements Listener {
    2.  
    3. String ohmregex = "|ohm|";
    4. String omegaregex = "|omega|";
    5. String omega = "Ω";
    6.  
    7. String test = "testin1";
    8. String test2 = "testing2";
    9. @EventHandler
    10. public void onPlayerChat(AsyncPlayerChatEvent e) {
    11.  
    12. Player p = e.getPlayer();
    13.  
    14. if (p.isOnline()) {
    15.  
    16.  
    17. if (e.getMessage().contains("|omega|")||(e.getMessage().contains("|ohm|"))) {
    18.  
    19. e.getMessage().replaceAll(omegaregex, omega);
    20. e.getMessage().replaceAll(ohmregex, omega);
    21.  
    22.  
    23. }
    24.  
    25. }
    26. }
    27.  
    28.  
    29. }
    30.  

    It loads fine and there are no errors, but its not working. Is it because i'm using special characters? I know its probably a simple mistake, but I couldn't figure it out! Any help is appreciated, thanks!
     
  2. Offline

    Skye

  3. Offline

    fireblast709

    ryryanator In addition to the previous post, use replace() instead of replaceAll() (since you don't seem to regex).
     
  4. Offline

    ryryanator

Thread Status:
Not open for further replies.

Share This Page