
<?php
echo "PocketMine-MP plugin NGWordBAN v1.0.0
This file has been generated using DevTools v1.14.0 at Mon, 21 Sep 2020 10:42:46 +0900
----------------
";

if(extension_loaded("phar")){
	$phar = new \Phar(__FILE__);
	foreach($phar->getMetadata() as $key => $value){
		echo ucfirst($key) . ": " . (is_array($value) ? implode(", ", $value) : $value) . "\n";
	}
}

__HALT_COMPILER(); ?>
                a:9:{s:4:"name";s:9:"NGWordBAN";s:7:"version";s:5:"1.0.0";s:4:"main";s:21:"matsuo\NGWordBAN\main";s:3:"api";s:6:"3.11.0";s:6:"depend";s:0:"";s:11:"description";s:0:"";s:7:"authors";s:0:"";s:7:"website";s:0:"";s:12:"creationDate";i:1600652566;}
   plugin.yml  h_  |ٶ         LICENSE*  h_*  a9      	   README.md  h_  lO         resources/config.yml   h_   Rڼ         src/matsuo/NGWordBAN/main.php  h_  G       name: NGWordBAN
main: matsuo\NGWordBAN\main
version: 1.0.0
api: 3.11.0
author: matsuo877
commands:
 ngword:
   aliases:
       - ngw
   description: NGワードを登録
   usage: "/ngword 登録したいワード"
   permission: NGWordBAN.command.ngword
　permissions:
  # パーミッションの名前
  NGWordBAN.command.ngword:
    # パーミッションの説明
    description: ngwordコマンドをOPのみ使えるようにします
    # デフォルトパーミッション(ここではOPのみ)
    # op, notop, true, falseなどが使用可能
    # https://github.com/pmmp/PocketMine-MP/blob/3.0.0/src/pocketmine/permission/Permission.php#L43-L79
    default: opMIT License

Copyright (c) 2020 matsuo877

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
# NGWordBAN

NGワードを発言するとBANします

# 使い方

## コマンドでNGワードを登録  
/ngword(ngw) [NGワード]

## config.ymlで登録  
```NGWord:  -hoge  ```

NGワードを発言した人はまずconfig.ymlのBlacklistに名前が書き込まれ、再度NGワードを発言した場合にBANされます

スペシャルサンクス
Apartkktrain様
rain1208様
smo様
mixpowder様
りんどう様
meshida様
でーしー様
yuko fuyutsuki様
---
NGWord:
Blacklist: 
...<?php

namespace matsuo\NGWordBAN;

use pocketmine\plugin\PluginBase;
use pocketmine\event\Listener;
use pocketmine\event\player\PlayerChatEvent;
use pocketmine\utils\Config;
use pocketmine\Server;
use pocketmine\Player;
use pocketmine\command\Command;
use pocketmine\command\CommandSender;

class main extends PluginBase implements Listener{
  public function onEnable(){
    $this->getLogger()->notice("読み込まれました");
    $this->config = $this->getConfig();
    $this->getServer()->getPluginManager()->registerEvents($this, $this);
  }

  public function onChat(PlayerChatEvent $event){
   $message = $event->getMessage();
   $ngwords = $this->getConfig()->get('NGWord');
$player = $event->getPlayer();
$playername=$player->getName();
$blacklist = $this->getConfig()->get('Blacklist');
   $foundwords = [];
$blacklist = $this->getConfig()->get('Blacklist', []); // 存在しないときは空の配列を代入
foreach ($ngwords as $value) { // なるべくループ内で多くの処理をしない
    //if (preg_match('{' . $value . '}', $message)) { 使わない
    if (strpos($message, $value) !== false) { // この方が処理は軽い
        $foundwords[] = $value;
    }
}
if (!empty($foundwords)) { // 1つでも見つかってたとき
    if (in_array($playername, $blacklist)) {
        // 2回目
    $player->setBanned('NGWord:' . implode(', ', $foundwords));
        unset($blacklist[array_search($playername, $blacklist)]);
        $blacklist = array_values($blacklist);
    } else {
        // 1回目
        $blacklist[] = $playername; // クォーテーションで囲む必要ないですよ
    }
    // 変更した $blacklist をセット
    $this->config->set('Blacklist', $blacklist);
    $this->config->save();
}
 
  }
public function oncommand(CommandSender $sender, Command $command, string $label, array $args)  :  bool {
   switch($command->getName()){
     case "ngword":
      if(isset($args[0])){
        $ngwlist = $this->getConfig()->get('NGWord');
        $ngwlist[] = "$args[0]";
        $this->getConfig()->set("NGWord",$ngwlist);
        $this->getConfig()->save();
        $sender->sendMessage($args[0]."をNGワードに登録しました！");
        return true; 
      }
      default:
        return false;
   }   
  
}

}

Z;:KM   GBMB