[HOW TO] Create an simple/powerful antiswear

Oct 22, 2016
[HOW TO] Create an simple/powerful antiswear
  • Download the Antiswear API by the #1 Antiswearing plugin ( https://github.com/BSwear/Antiswear-API )

    import java.util.List;

    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.AsyncPlayerChatEvent;
    import org.bukkit.permissions.Permission;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.configuration.file.FileConfiguration;

    //The Antiswear API classes
    import io.github.bswearteam.bswearapi.AntiswearAPI;

    Code (Text):

    package your.package.here;

    // Put the imports from the 'Show java imports' button here!!!!

    * @Author The BSwear Team
    public class SwearBlocker implements Listener {

       public final Permission BYPASS_PERM = new Permission("bswear.bypass"); // If the user has this permission then the blocker will be canceled

       public void OnChat(AsyncPlayerChatEvent event) {
          Player player = event.getPlayer();
          if (!player.hasPermission(BYPASS_PERM)) {
             String msg = event.getMessage().toLowerCase().replaceAll("[-_*. ]", "");

             for (String words : getConfig().getStringList("words")) {
                 BlockWord(event, words); // Use this if you what to block just that word in the chat msg
                 BlockMessage(event, words); // Use this if you what to block the whole chat msg with that word
                 ReplaceWord(event, words, "text to replace the word with"); // Use this if you what to replace the word in the chat with an new one

    Applied By isaiah8139: Aug 24, 2016 at 1:25 PM
  • Loading...
  • Loading...