Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/reinfyteam/libpf
https://github.com/reinfyteam/libpf
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/reinfyteam/libpf
- Owner: ReinfyTeam
- License: mit
- Created: 2022-09-26T05:14:08.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-10-01T09:24:41.000Z (over 2 years ago)
- Last Synced: 2023-08-18T08:11:32.979Z (over 1 year ago)
- Language: PHP
- Size: 18.6 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
### libpf (ProfanityFilter Library)
This is a based virion api plugin for developers.
Use [DeVirion](https://poggit.pmmp.io/p/DeVirion) or [VirionTool](https://poggit.pmmp.io/p/VirionTool) to inject the code or download this source code.# How to use the code?
An [example plugin](https://github.com/ReinfyTeam/ProfanityFilter-ExamplePlugin) can give you an example of basic usage of api.
1. Import the class first.
```php
use ReinfyTeam\libpf\ProfanityFilter;
```
2. Import the chat event class & write the following:
```php
use pocketmine\event\Listener;
use pocketmine\event\player\PlayerChatEvent;
```
```php
public function onChat(PlayerChatEvent $event) : void{ // the function event
if(ProfanityFilter::detectProfanity($event->getMessage(), ["test"])){
$event->cancel(); // cancel the chat event
$event->getPlayer()->sendMessage("§cPlease Watch your language!"); // the warning message
}
}
```
- Removing the unicode messages
You can use the following:
```php
ProfanityFilter::removeUnicode($message, false); // This removes ONLY non-printable characters like ®
ProfanityFilter::removeUnicode($message, true); // This removes non-printable AND other mcpe characters such as emoji.
```
- You can use default profanity list by:
```php
ProfanityFilter::defaultProfanity(); // returns array can be used as:ProfanityFilter::detectProfanity($message, ProfanityFilter::defaultProfanity());
```Made by ReinfyTeam :heart: