Skip to content
This repository has been archived by the owner on Jul 11, 2022. It is now read-only.

Simple Configuring

Ace Sobremont edited this page Jul 2, 2022 · 2 revisions

Simple Configuring

Make sure you have list of profanities that will be use.

$words = ["your-word","another-word"];

Or simplify it on your config.

$words = $this->getConfig()->get("profanity-words");

Your config must be formatted like this:

profanity-words:
   - "your-word"
   - "another-word"

Make sure its in array otherwise cause of error's.

Simple Detecting

This how's formatted to use the function.

PluginAPI::detectProfanity(string $message, array $words)

Now $words can be defined here

You can now execute these plugin api by using this method:

use pocketmine\event\Listener;
use pocketmine\event\player\PlayerChatEvent;
use xqwtxon\ProfanityFilter\PluginAPI;

class Example implements Listener {
     public function onChat(PlayerChatEvent $ev): void {
     $player = $ev->getPlayer();
     $message = $ev->getMessage();
     $words = ["your-word","another-word"];
     if(PluginAPI::detectProfanity($message, $words)){
         $ev->cancel();
         $player->sendMessage("Watch your language!");
     }
}

This is one of my examples which working as of now.

Do you want to improve this page?

You can make your own pull request.

Clone this wiki locally