Skip to content
This repository has been archived by the owner on Jul 11, 2022. It is now read-only.
Ace Sobremont edited this page Jun 27, 2022 · 14 revisions

Introduction

Welcome to Plugin Wiki, Here's the basic of sequence in structure of Plugin API. It's introduce the speech of the chat block them.

Why you should use this one?

It is easy to find out more with profanities. Make sure you have listed of profanities want you to block.

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