Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private List<String> words = new ArrayList<>();
- private List<String> replace = new ArrayList<>();
- @EventHandler
- public void doStuff(AsyncPlayerChatEvent e) {
- /**
- * prolly set up the words somewhere so they aren't set up with every
- * chat message, sounds laggy
- */
- //make these as you need
- words.add("fuck"); // index 0
- words.add("shit"); // 1
- replace.add("frick"); // index 0
- replace.add("shot"); // 1
- String message = e.getMessage();
- int indexes = 0;
- // iterate through words
- for (String s : words) {
- indexes++;
- indexes -= 1; // this should make sure that the first variables in the lists are not skipped
- if (message.contains(s)) {
- message.replaceAll(s, replace.get(indexes));
- //this SHOULD work, but I haven't touched java or bukkit in like a month.. sorry
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement