Advertisement
Guest User

Untitled

a guest
Jun 28th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.84 KB | None | 0 0
  1. private List<String> words = new ArrayList<>();
  2.     private List<String> replace = new ArrayList<>();
  3.  
  4.     @EventHandler
  5.     public void doStuff(AsyncPlayerChatEvent e) {
  6.         /**
  7.          * prolly set up the words somewhere so they aren't set up with every
  8.          * chat message, sounds laggy
  9.          */
  10.  
  11.         //make these as you need
  12.        
  13.         words.add("fuck"); // index 0
  14.         words.add("shit"); // 1
  15.  
  16.         replace.add("frick"); // index 0
  17.         replace.add("shot"); // 1
  18.  
  19.         String message = e.getMessage();
  20.         int indexes = 0;
  21.         // iterate through words
  22.         for (String s : words) {
  23.             indexes++;
  24.             indexes -= 1; // this should make sure that the first variables in the lists are not skipped
  25.        
  26.             if (message.contains(s)) {
  27.                 message.replaceAll(s, replace.get(indexes));
  28.                 //this SHOULD work, but I haven't touched java or bukkit in like a month.. sorry
  29.             }
  30.         }
  31.  
  32.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement