Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.DivinityRealms.AntiSwear;
- import net.md_5.bungee.api.ChatColor;
- import org.bukkit.Bukkit;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.player.AsyncPlayerChatEvent;
- import org.bukkit.plugin.java.JavaPlugin;
- public class Main extends JavaPlugin implements Listener{
- @EventHandler
- public void onPlayerChat(AsyncPlayerChatEvent e){
- for(String word : e.getMessage().split(" ")){
- String word2 = word.toLowerCase();
- //This will allow words to be in any casing as long as the letters remain the same.
- //So for example, "test" would be the same as "TeST"..
- if(getConfig().getStringList("bannedwords").contains(word2)){
- e.setCancelled(true);
- //Cancells out the message from the player
- e.getPlayer().sendMessage(ChatColor.LIGHT_PURPLE + "Do You Kiss Your Mother With That Mouth!?");
- //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.
- }
- }
- }
- public void onEnable(){
- System.out.println("Divinity Hub Plugin Enabled");
- getConfig().options().copyDefaults(true);
- saveConfig();
- Bukkit.getServer().getPluginManager().registerEvents(this, this);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement