Advertisement
Guest User

Untitled

a guest
Jan 29th, 2015
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. package com.DivinityRealms.AntiSwear;
  2.  
  3. import net.md_5.bungee.api.ChatColor;
  4.  
  5. import org.bukkit.Bukkit;
  6. import org.bukkit.event.EventHandler;
  7. import org.bukkit.event.Listener;
  8. import org.bukkit.event.player.AsyncPlayerChatEvent;
  9. import org.bukkit.plugin.java.JavaPlugin;
  10.  
  11. public class Main extends JavaPlugin implements Listener{
  12.  
  13. @EventHandler
  14. public void onPlayerChat(AsyncPlayerChatEvent e){
  15. for(String word : e.getMessage().split(" ")){
  16. String word2 = word.toLowerCase();
  17. //This will allow words to be in any casing as long as the letters remain the same.
  18. //So for example, "test" would be the same as "TeST"..
  19. if(getConfig().getStringList("bannedwords").contains(word2)){
  20. e.setCancelled(true);
  21. //Cancells out the message from the player
  22. e.getPlayer().sendMessage(ChatColor.LIGHT_PURPLE + "Do You Kiss Your Mother With That Mouth!?");
  23. //This would not only send a warning to the player, but also point out what word caused this event to occur - so if it was on accident, the player would know what he typed wrong.
  24. }
  25. }
  26. }
  27.  
  28.  
  29. public void onEnable(){
  30. System.out.println("Divinity Hub Plugin Enabled");
  31. getConfig().options().copyDefaults(true);
  32. saveConfig();
  33. Bukkit.getServer().getPluginManager().registerEvents(this, this);
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement