Use the API!

The plugin provides an API that you can use. For now it only contains events that are fired when a message is censored or deleted.

Importing the API

<repository>
  <id>synkdev-repo-releases</id>
  <name>SynkDev Repository</name>
  <url>https://maven.synkdev.cc/releases</url>
</repository>

<dependency>
  <groupId>cc.synkdev</groupId>
  <artifactId>ChatWatchdogAPI</artifactId>
  <version>1.0</version>
  <scope>compile</scope>
</dependency>

Maven

maven {
    url "https://maven.synkdev.cc/releases"
}

implementation "cc.synkdev:ChatWatchdogAPI:1.0"

Gradle

Usage examples

package cc.synkdev.example;

public class Main extends JavaPlugin implements Listener {
   
    @Override
    public void onEnable() {
       //register the EventHandlers
        Bukkit.getPluginManager().registerEvents(this, this);
    }
   
    @EventHandler
    public void onDelete(MessageDeleteEvent event) {
        for (Player p : Bukkit.getOnlinePlayers()) {
           if (((OfflinePlayer) p).isOp()) {
              p.sendMessage(event.getPlayer().getName()+"'s message was just deleted! Here it is:\n"+event.getMessage()));
              //this will broadcast to all op players that the player has swore in chat
           }
        }
    }
   
    @EventHandler
    public void onCensor(ChatCensorEvent event) {
        for (Player p : Bukkit.getOnlinePlayers()) {
           if (((OfflinePlayer) p).isOp()) {
              p.sendMessage(event.getPlayer().getName()+"'s message was just censored! Here it is:\n"+event.getMessage()));
              //this will broadcast to all op players that the player has swore in chat
           }
        }
    }
   
}

With Spigot: Here I am sending to all OP players that the player has swore in chat.

package cc.synkdev.example;

public class Main extends Plugin implements Listener {
    
    @Override
    public void onEnable() {
        getProxy().getPluginManager().registerListener(this, this);
    }
    
    @EventHandler
    public void onDelete(MessageDeleteEvent event) {
        getProxy().broadcast(event.getPlayer().getName()+" just swore.");
        getProxy().broadcast("Don't be like "+ event.getPlayer().getName()+"!");
        getProxy().broadcast("Don't say "+event.getMessage());
    }
} 

With BungeeCord: Here I am sending a message to all players on the proxy when a message gets deleted (please don't do that)

An example use case would be to interact with a punishment plugin to punish the player when they get censored.

Last updated